In [1]:
import matplotlib as mpl
import pandas as pd
import random
In [2]:
import mplstyle
import mplstyle.styles.simple as simple_style
In [3]:
# Save the current style parameters to a variable
base_style = mplstyle.get()
In [4]:
# Create a random data frame
def rand_vect(n):
    return reduce(lambda m, x: m + [ m[-1] + random.random() - 0.5 ], range(n), [ random.random() ])

df = pd.DataFrame([ rand_vect(10) for x in range(5) ]).T
In [5]:
# Shorthand function creating the plot
def plot_df(): 
    df.plot(grid=True)
In [6]:
# What the plot looks like before applying additional styles
plot_df()
In [7]:
# Now let's see what it looks like with the "pastel" style
mplstyle.set(simple_style)
mplstyle.set({ "lines": { "markersize": 4, "markeredgewidth": 0, "marker": "o" }})
plot_df()
In [8]:
# Example of passing keyword argument to a style module
mplstyle.set(simple_style, palette=mpl.cm.Pastel1)
plot_df()
In [9]:
# We can also layer on additional style rules,
# using nested dictionaries or dot notation, or both.
mplstyle.set({
    "figure.figsize": (10, 8),
    "lines": {
        "marker": "s",
        "markeredgewidth": 0.5
    }
})
plot_df()
In [10]:
# And revert back to our original style rules...
mplstyle.reset(base_style)
plot_df()