matplotlib - python gridspec, trouble sharing x and y axis -


i'm doing multi panel plot using gridspec, i'm having few issues. want each row share different y axis , each column share different x axis. or, in other words, share x per row , share y per column. want add label each of these axis. here example of i'm talking along code made (minus axis labels want): sample axis sharing http://matplotlib.org/_images/subplots_demo_04.png

# row , column sharing f, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2, 2, sharex='col', sharey='row') ax1.plot(x, y) ax1.set_title('sharing x per column, y per row') ax2.scatter(x, y) ax3.scatter(x, 2 * y ** 2 - 1, color='r') ax4.plot(x, 2 * y ** 2 - 1, color='r') 

however can't use implementation because using subplot2grid need choose specific positions , dimensions of each plot. i've tried using sharex=ax1 , sharey = ax1 in subplot2grid call no avail. here relevant portion of code:

ax1 = plt.subplot2grid((8,8), (2,0), colspan=2, rowspan=2) ax2 = plt.subplot2grid((8,8), (4,0), colspan=2, rowspan=2) ax3 = plt.subplot2grid((8,8), (6,0), colspan=2, rowspan=2) ax4 = plt.subplot2grid((8,8), (2,2), colspan=2, rowspan=2) ax5 = plt.subplot2grid((8,8), (4,2), colspan=2, rowspan=2) ax6 = plt.subplot2grid((8,8), (2,4), colspan=2, rowspan=2) ax7 = plt.subplot2grid((8,8), (1,0), colspan=2, rowspan=1) ax8 = plt.subplot2grid((8,8), (1,2), colspan=2, rowspan=1) ax9 = plt.subplot2grid((8,8), (1,4), colspan=2, rowspan=1) ax10 = plt.subplot2grid((8,8), (2,6), colspan=1, rowspan=2) 

in contrast normal subplots, subplots using sharex/sharey=ax subplot2grid or gridspec not share range, ticks.

to configure ticks each subplot separately need plt.setp(ax.get_xticklabels(), visible=false), see gridspec shared axes in python more details.


Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -