Wednesday, April 4, 2012

Less is More with matplotlib

import pylab as pl

#  Remove tick marks and tick labels
pl.xticks([]) 
pl.yticks([])

#  Remove axis lines
pl.gca().set_frame_on(False)

#  remove tick marks, leave label
pl.gca().xaxis.set_ticks_position('none')
pl.gca().yaxis.set_ticks_position('none')

# every other tick
pl.yticks(pl.yticks()[0][::2])
pl.xticks(pl.xticks()[0][::2])

# ticks on left and bottom only
pl.gca().get_xaxis().tick_bottom()
pl.gca().get_yaxis().tick_left()