Skip to content

Latest commit

 

History

History
39 lines (29 loc) · 1.15 KB

File metadata and controls

39 lines (29 loc) · 1.15 KB

Matplotlib style sheets

This repository was inspired by a post on my blog related to the use of style sheets on Matplotlib. The main idea is to create a file with some of the parameters that want to be defined.

How to use it?

You can use the URL for the style sheet in Python, as the example below.

import numpy as np
import matplotlib.pyplot as plt

repo = "https://raw.githubusercontent.com/nicoguaro/matplotlib_styles/master"
style = repo + "/styles/clean.mplstyle"
with plt.style.context(style):
    x = np.linspace(0, 4, 201)
    cos = np.cos(np.pi*x)
    sin = np.sin(np.pi*x)
    plt.plot(x, sin, x, cos)
    plt.xlabel("x")
    plt.ylabel("y")
    plt.savefig("sin_cos-ex.svg")

You should get the following result

Example of use of style sheets

How to contribute?

If you want to add style sheets to the repository in some of the groups you can create a Pull Request with the new file under the folder styles.

License

Style sheets and code are availabe under MIT license.