python - tick marks in matplotlib -


i creating subplot using matplotlib, top x-axis different bottom x-axis. added xticks , xlabels top myself.

i there xtick marks corresponding bottom x-axis @ bottom of middle , top subplots, xticks point outwards (or down) - @ bottom. there way this?

this code using far customize ticks:

f, (ax1, ax2, ax3) = plt.subplots(3, sharex=false, sharey=false) f.subplots_adjust(hspace=0) plt.setp([a.get_xticklabels() in f.axes[:-1]], visible=false)  ax3.get_xaxis().set_tick_params(direction='out', top='off', which='both') ax2.get_xaxis().set_tick_params(direction='out', bottom='on', top='off', which='both')   ax1.minorticks_off() ax1.get_xaxis().tick_top() ax1.set_xticks([np.divide(1.0,100.0), np.divide(1.0,50.0), np.divide(1.0,35.0),                 np.divide(1.0,20.0), np.divide(1.0,10.0), np.divide(1.0,5.0),                 np.divide(1.0,3.0), np.divide(1.0,2.0), np.divide(1.0,1.0)]) ax1.set_xticklabels([100, 50, 35, 20, 10, 5, 3, 2, 1]) 

i finding since made customized xticks top plot, can't this, , specifying direction 'out' in bottom subplot ruins tick marks in middle. since there no space between subplots, top of bottom plot shares x-axis bottom of middle subplot, etc...

is there workaround this?

enter image description here

you can draw middle axes above bottom axes setting respective z orders. top ticks can done w/a call axvline.

import matplotlib.pyplot plt import numpy np  f, (ax1, ax2, ax3) = plt.subplots(3, sharex=false, sharey=false) f.subplots_adjust(hspace=0) plt.setp([a.get_xticklabels() in f.axes[:-1]], visible=false)  ax3.get_xaxis().set_tick_params(direction='out', top='off', which='both') ax2.get_xaxis().set_tick_params(direction='out', bottom='on', top='off', which='both')   ax1.minorticks_off() ax1.get_xaxis().tick_top() ax1.set_xticks([np.divide(1.0,100.0), np.divide(1.0,50.0), np.divide(1.0,35.0),                 np.divide(1.0,20.0), np.divide(1.0,10.0), np.divide(1.0,5.0),                 np.divide(1.0,3.0), np.divide(1.0,2.0), np.divide(1.0,1.0)]) ax1.set_xticklabels([100, 50, 35, 20, 10, 5, 3, 2, 1])  i, ax in enumerate((ax3, ax2, ax1)):     ax.set_zorder(i) tick in ax2.xaxis.get_ticklocs():     ax2.axvline(tick, ymin=0.9) plt.show()     

Comments

Popular posts from this blog

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

python - How do I create a list index that loops through integers in another list -

c# - “System.Security.Cryptography.CryptographicException: Keyset does not exist” when reading private key from remote machine -