Cookbook/Matplotlib/ThickAxes - SciPy wiki dump

This is an archival dump of old wiki content --- see scipy.org for current material.
Please see http://scipy-cookbook.readthedocs.org/

Example of how to thicken the lines around your plot (axes lines) and to get big bold fonts on the tick and axis labels.

 1 from pylab import *
 2 
 3 # Thicken the axes lines and labels
 4 # 
 5 # Comment by J. R. Lu:
 6 # I couldn't figure out a way to do this on the 
 7 # individual plot and have it work with all backends
 8 # and in interactive mode. So, used rc instead.
 9 # 
 10 rc('axes', linewidth=2)
 11 
 12 # Make a dummy plot
 13 plot([0, 1], [0, 1])
 14 
 15 # Change size and font of tick labels
 16 # Again, this doesn't work in interactive mode.
 17 fontsize = 14
 18 ax = gca()
 19 
 20 for tick in ax.xaxis.get_major_ticks():
 21  tick.label1.set_fontsize(fontsize)
 22  tick.label1.set_fontweight('bold')
 23 for tick in ax.yaxis.get_major_ticks():
 24  tick.label1.set_fontsize(fontsize)
 25  tick.label1.set_fontweight('bold')
 26 
 27 xlabel('X Axis', fontsize=16, fontweight='bold')
 28 ylabel('Y Axis', fontsize=16, fontweight='bold')
 29 
 30 # Save figure
 31 savefig('thick_axes.png')

thick_axes.png

SciPy: Cookbook/Matplotlib/ThickAxes (last edited 2015年10月24日 17:48:25 by anonymous)

AltStyle によって変換されたページ (->オリジナル) /