XKCD-style Plot using matplotlib
Goal¶
This post aims to introduce how to plot the data using matplotlib
in an XKCD style.
Libraries¶
In [1]:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
Create data to plot¶
In [2]:
x = np.linspace(-np.pi, np.pi, 100)
df_data = pd.DataFrame(data={'sin x': np.sin(x), 'cos x': np.cos(x)}, index=x)
df_data.head()
Out[2]:
In [3]:
df_data.plot(title='Normal Matplotlib Style');
In [4]:
with plt.xkcd():
df_data.plot(title='XKCD Style');