Skip to content Skip to sidebar Skip to footer

Getting Ticks In Figure With Subplots

I have a complicated figure made in matplotlib with three subplots, two of which have twin axes. It works well except there are no tick marks in the figure and I can't figure out h

Solution 1:

The white seaborn style is turning off the ticks. You can instead choose the ticks style with

sns.set_style("ticks")

by default this will have the ticks going outwards. To manually add ticks going inward you can do something like

sns.set_style("white", {'xtick.direction': u'in', 'xtick.major.size': 5.0, 'xtick.minor.size': 2.0,
                        'ytick.direction': u'in', 'ytick.major.size': 5.0, 'ytick.minor.size': 2.0})

Solution 2:

You can also reset the length of the ticks using tick_params:

ax1.tick_params('both', length=3, width=1, which='major')

which causes ticks to appear on each of the sides of the subplot, if you want it on just one side, for example left, and bottom, you can do this:

ax1.xaxis.tick_bottom()
ax1.yaxis.tick_left()

Post a Comment for "Getting Ticks In Figure With Subplots"