Matplotlib 绘图坐标轴设置

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl
mpl.rcParams['font.family'] = 'Helvetica Neue'
import prettyplotlib as ppl
from prettyplotlib import brewer2mpl

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

fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
np.random.seed(42)
plt.plot(np.random.randn(1000).cumsum(), color=color1, alpha=1)
ticks = ax.set_xticks([0, 250, 500, 750, 1000])
labels = ax.set_xticklabels(['one', 'two', 'three', 'four', 'five'],
                            rotation=45, rotation_mode='anchor',
                            ha="right", position=(0, 0.01))
plt.savefig('set_xticklabels.png')

Image Title

2014-05-17 20:0628PythonMatplotlib
comments powered by Disqus