Tickmarks in matplotlib

Over time I’ve become more and more a lover of Python. I still don’t use half of the fancy stuff and very much use it as a scripting language, but as you can see from some previous posts I really do think that it is well suited for astronomical purposes. Anyway, I digress, one thing that was bugging me was producing publication quality plots. I’ve still got things to tweak with my plots but I think I’m finally happy with my script and thought I’d share one vital thing – tickmark lenghts. It took me ages to figure out what paramter this was called and lets be honest if no body else gets any use from this I’m bound to the next time I forget / can’t find any code with this implmeneted in. So here we go, how change tickmark lengths in matplotlib:

import string, sys, math, scipy, numpy, pylab
from pylab import *
x = [0,1,2,3,4]; y = [2,3,4,5,6]
fig = plt.figure(figsize=(9, 8))
fig.subplots_adjust(left=None, bottom=0.2, right=None, top=0.97,wspace=None, hsp
ax1 = fig.add_subplot(111)
setp(gca().get_ymajorticklabels(), fontsize=’large’)
setp(gca().get_xmajorticklabels(), fontsize=’large’)
labels = setp(gca(), ylabel=’y axis’, xlabel=’x axis’)
setp(labels, fontsize=’large’)
for l in ax1.get_xticklines() + ax1.get_yticklines():
for l in ax1.yaxis.get_minorticklines()+ax1.xaxis.get_minorticklines():
save = “test.eps”


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: