Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make longer subplot tick marks in matplotlib?

Tags:

I am trying to alter the tick marks along the axes of a python multipanel subplot. I have two panels that share a common x-axis. I have made the border around the plot thicker as well as making all of the tick marks along the axes thicker. I have two questions:

How can I make all tick marks (both axes) longer so they are more visible?

How do I add smaller but still noticable tick marks between major tick marks?

Here is a minimum working example of what I have so far.

from numpy import * from scipy import * from pylab import * from random import * import pylab import matplotlib.pyplot as plt   #make the axis border thick pylab.rc("axes", linewidth=4.0) pylab.rc("lines", markeredgewidth=4)   #create a figure with two panels that shares the x-axis f, (ax1, ax2) = plt.subplots(2, sharex=True, sharey=False) #example figure1 ax1.plot(range(2),range(2),linewidth=2) #example figure 2 ax2.plot(range(2),range(2),linewidth=2)    # Fine-tune figure; make subplots close to each other and hide x ticks for # all but bottom plot. f.subplots_adjust(hspace=0) plt.setp([a.get_xticklabels() for a in f.axes[:-1]], visible=False) show() 
like image 924
user1139975 Avatar asked Jan 22 '13 00:01

user1139975


People also ask

How do I increase the spacing between ticks in MatPlotLib?

The spacing between ticklabels is exclusively determined by the space between ticks on the axes. Therefore the only way to obtain more space between given ticklabels is to make the axes larger.


1 Answers

Try the following:

#example figure1 ax1.plot(range(2),range(2),linewidth=2) ax1.minorticks_on() ax1.tick_params('both', length=20, width=2, which='major') ax1.tick_params('both', length=10, width=1, which='minor') 

You can repeat the same for ax2. Does this work for you?

like image 83
crayzeewulf Avatar answered Oct 27 '22 10:10

crayzeewulf