« Calgary Comic Expo 2010 | Main | FAS Newsletter - article about Arecibo »

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 * 
#DATA 
x = [0,1,2,3,4]; y = [2,3,4,5,6] 
#Plotting 
fig = plt.figure(figsize=(9, 8)) 
fig.subplots_adjust(left=None, bottom=0.2, right=None, top=0.97,wspace=None, hsp
ace=None)

ax1 = fig.add_subplot(111)
ax1.semilogx(x,y)
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():
l.set_markersize(6)
l.set_markeredgewidth(1.2)

for l in ax1.yaxis.get_minorticklines()+ax1.xaxis.get_minorticklines():
l.set_markersize(3)
l.set_markeredgewidth(1.2)


save = "test.eps"
pylab.savefig(save)



TrackBack

TrackBack URL for this entry:
http://www.krioma.net/cgi-bin/mt_new/mt-tb.cgi/441

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

About

This page contains a single entry from the blog posted on May 6, 2010 4:14 AM.

The previous post in this blog was Calgary Comic Expo 2010.

The next post in this blog is FAS Newsletter - article about Arecibo.

Many more can be found on the main index page or by looking through the archives.

Get Firefox! Valid XHTML 1.0! Valid CSS! RSS Feed BlogUniverse - listed Powered by Apache Creative Commons License ringsofsaturnrock's Most Interesting Photos on Flickriver

Powered by
Movable Type 3.33