Python 科学计算绘图工具 Matplotlib 小清新配色

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import numpy as np
import matplotlib.pyplot as plt
from numpy.random import randn
import matplotlib as mpl
mpl.rcParams['font.family'] = 'Helvetica Neue'
import prettyplotlib as ppl
from prettyplotlib import brewer2mpl

np.random.seed(64)

set2 = brewer2mpl.get_map('Set2', 'qualitative', '8').mpl_colors
color1, color2, color3= set2[0], set2[1], set2[3]

fig = plt.figure()

ax1 = fig.add_subplot(221)
ppl.hist(randn(100), color=color1, bins=20, grid='y')

ax2 = fig.add_subplot(222)
ppl.scatter(np.arange(0, 30, 0.1), np.arange(0, 30, 0.1) + 3*randn(300),
            color=color2, alpha=1)

ax3 = fig.add_subplot(223)
ppl.plot(randn(50).cumsum(), 'o--', color=color3)

ax4 = fig.add_subplot(224)
ppl.pcolormesh(fig, ax4, randn(10, 10))
plt.savefig("ppl.png")
plt.show()

Image Title

comments powered by Disqus