Speaking of graphs in python, it is matplotlib, but since it is a bit bad, I think I use seaborn to draw a beautiful graph.
seaborn can easily draw beautiful graphs, but in the presentation materials of the study session We recommend a library that draws handwritten graphs.
XKCD-stlye seems to be built into matplotlib, so Just write one line at the beginning.
import matplotlib.pyplot as plt
plt.xkcd()
Here are some of the graphs that look like. There are many other samples on the matplotlib glallery page (http://matplotlib.org/xkcd/gallery.html).
x = np.arange(-3, 3, 0.1)
y = np.sin(x)
plt.plot(x, y, c='lightskyblue', label='y = sin(x)')
plt.plot([-3, 3], [-1, 1], c='lightcoral', label='y = 1/3x')
plt.legend()
plt.title('Line Plot')
plt.xlabel('x')
plt.ylabel('y')
plt.show()
N = 50
x = np.random.rand(N)
y = np.random.rand(N)
area = np.pi * (15 * np.random.rand(N))**2
plt.title('Scatter Plot')
plt.scatter(x, y, s=area, alpha=0.5, c='gold')
plt.show()
plt.hist(np.random.randn(1000), color='yellowgreen')
plt.title('Histgram')
plt.show()
x = np.array([0.2, 0.4, 0.15, 0.25])
labels = ['Melon', 'Banana', 'Grape', 'Apple']
colors = ['yellowgreen', 'gold', 'lightskyblue', 'lightcoral']
plt.pie(x, autopct='%d%%', labels=labels, colors=colors)
plt.axis('equal')
plt.title('Pie Chart')
plt.show()
Recommended Posts