Matplotlib:加粗轴线¶
日期 | 2008-12-02(最后修改),2008-12-02(创建) |
---|
如何加粗绘图周围的线条(轴线)以及在刻度和轴标签上使用粗体字体的示例。
In [1]
from pylab import *
# Thicken the axes lines and labels
#
# Comment by J. R. Lu:
# I couldn't figure out a way to do this on the
# individual plot and have it work with all backends
# and in interactive mode. So, used rc instead.
#
rc('axes', linewidth=2)
# Make a dummy plot
plot([0, 1], [0, 1])
# Change size and font of tick labels
# Again, this doesn't work in interactive mode.
fontsize = 14
ax = gca()
for tick in ax.xaxis.get_major_ticks():
tick.label1.set_fontsize(fontsize)
tick.label1.set_fontweight('bold')
for tick in ax.yaxis.get_major_ticks():
tick.label1.set_fontsize(fontsize)
tick.label1.set_fontweight('bold')
xlabel('X Axis', fontsize=16, fontweight='bold')
ylabel('Y Axis', fontsize=16, fontweight='bold')
# Save figure
savefig('thick_axes.png')
章节作者:jesrl
附件