XKCD-style Plot using matplotlib
Goal¶
This post aims to introduce how to plot the data using matplotlib
in an XKCD style.
Libraries¶
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
Create data to plot¶
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()
df_data.plot(title='Normal Matplotlib Style');
with plt.xkcd():
df_data.plot(title='XKCD Style');