Thursday, October 13, 2011

More python plotting tricks

I absolutely love these python plotting page with examples:
http://matplotlib.sourceforge.net/gallery.html
http://www.scipy.org/Cookbook/Matplotlib

Today I figured out how to change the fonts of the legend on my plot, and add a shadow. (Pretty exciting I know.) I've also made the lines a little bit thicker, and different styles (so that it looks pretty in black and white printing of the paper).

Below is the code/plot:

from matplotlib.font_manager import fontManager, FontProperties
font= FontProperties(size=24);

fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot(chi, probsqso, 'k-', label = '$\mathrm{QSOs}$', linewidth=2.0)
ax.plot(chi, probsqsow, 'k:', label = '$\mathrm{QSOs\\ Weighted}$', linewidth=2.0)
ax.plot(chi, prob, 'k--', label = '$\mathrm{Gals}$', linewidth=2.0)

ax.set_xlabel("$\\chi$", fontsize=24)
ax.set_ylabel("$\mathrm{Normalized\ }dN/d\\chi$",fontsize=24)
pylab.legend(loc=2,shadow=True,prop=FontProperties(size=18))


No comments:

Post a Comment