In [3]:
%matplotlib inline
from matplotlib import pyplot as plt
import numpy as np
sorted(plt.style.available)
Out[3]:
In [4]:
def make_title(s):
return s.replace('-', ' ').replace('_', ' ').title()
def make_plots(style_str=None):
fig, axes_array = plt.subplots(2, 2)
((ax1, ax2), (ax3, ax4)) = axes_array
# sine and cosine line plots
x = np.arange(10)
y_sin = np.sin(x)
y_cos = np.cos(x)
ax1.plot(x, y_sin)
ax1.plot(x, y_cos)
ax1.set_title('sine and cosine line plots')
# a random scatter plot
points1 = np.random.rand(20,2)
points2 = np.random.rand(20,2)
ax2.scatter(points1[:, 0], points1[:, 1])
ax2.scatter(points2[:, 0], points1[:, 1])
ax2.set_title('a random scatter plot')
# a random bar graph
width = 0.4
middles = np.arange(1, 6)
heights1 = np.random.rand(5)
heights2 = np.random.rand(5)
ax3.bar(middles - width, heights1, width)
ax3.bar(middles, heights2, width)
ax3.set_title('a random bar graph')
# a random pie chart
values = np.random.rand(5)
frac_values = values/values.sum()
labels = ['A', 'B', 'C', 'D', 'E']
ax4.pie(frac_values, labels=labels)
ax4.set_title('a random pie chart')
# draw them!
fig.suptitle("{} (\'{}\')".format(make_title(style_str), style_str) if style_str else 'Default Settings', fontsize=20)
fig.subplots_adjust(hspace=0.3)
fig.set_size_inches(10, 10)
plt.show()
import seaborn
!)
In [5]:
make_plots()