python 2.7 - Why minor ticks disappear on pylab subplots -


begin edit

after initial post continued playing code. in subplots making 4 plots of same data set, each subplot having different time range. however, if give each subplot same time range minor ticks not disappear. may why deditos not reproduce issue.

that being said, if manually create each subplot (with each having different x-axis range), set minor tick locations, set each subplot's xrange not see minor ticks disappear until set ax3's (i.e. last subplot) range.

it seems issue in having different x-axis ranges. bizarre, think setting each axis' properties individually not tied together.

end edit

i creating 1 figure has 4 sub-plots, of time series. have xaxis major ticks spaced every 4 hours, , want minor ticks every hour. when set minor ticks first subplot (called ax1) minor ticks appear, should. however, when set minor ticks in ax2 show in ax2, minor ticks in ax1 disappear. repeats ax3, , ax4. so, in end have minor xaxis ticks in fourth subplot. had same problem yaxis, resolved issue using yaxis.set_minor_locator(multiplelocator(5)) each axis (see below). however, multiplelocator not seem work time series data. know how can keep minor xaxis ticks?

from pylab import * matplotlib.ticker import autominorlocator, multiplelocator minor = autominorlocator()  # start plotting fig = figure( figsize=(22,11) ) ax1 = fig.add_subplot(221) # 8-august 2011 ax2 = fig.add_subplot(222) # 9-august 2011 ax3 = fig.add_subplot(223) # 23-august 2011 ax4 = fig.add_subplot(224) # 24-august 2011  # repeated ax2, ax3, , ax4, yielding 2x2 grid of subplots.   # plot 8-august 2011 data ax1.plot(tpan.index,tpan.no2,'.-',markersize=10) ax1.errorbar(tacam.index,tacam.no2,yerr=0.15,fmt='r.',markersize=12)  # format plots suptitle('pandora/acam no$_2$ comparison', fontsize=22)  # define xtick locations/string labels xtickloc = [dt.datetime.combine(dates[0],dt.time())+dt.timedelta(hours=h) h in range(0,25,4)] xticklab = [dt.datetime.strftime(h,'%h:%m') h in xtickloc]  ax1.set_xlabel('hour of day (utc, est+5)',fontsize=14) ax1.set_ylabel('no$_2$ column density (molec*cm$^{-2}$ e16)',fontsize=14) ax1.xaxis.set_ticks(xtickloc) ax1.yaxis.set_ticks(linspace(0,1.5,7)) ax1.xaxis.set_minor_locator(minor) ax1.yaxis.set_minor_locator(multiplelocator(5)) ax1.set_xticklabels(xticklab,fontsize=12,fontweight='bold') ax1.set_yticklabels(linspace(0,1.5,7),fontsize=12,fontweight='bold') ax1.axis( (dates[0],dates[0]+dt.timedelta(days=1),-0.05,1.5),fontsize=6,fontweight='bold') ax1.tick_params(which='both',width=2,top='on') ax1.tick_params(which='major',length=7) ax1.tick_params(which='minor',length=4) ax1.grid(linestyle='-',which='major',linewidth=1) ax1.set_title('08-august 2011',fontsize=16) ax1.legend( ('pandora vcd','acam dscd'),loc=2,ncol=2) 

i facing same problem. think need is:

ax1.xaxis.set_minor_locator(autominorlocator()) 

instead of

ax1.xaxis.set_minor_locator(minor) 

you passing same object each of axes. object's contents modified when plot on ax4 based on range on subplot. hope helps.


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -