
#Define locations of colorbars for both subplot 1 and 2Ĭax1 = divider1.append_axes("right", size="5%", pad=0.05)Ĭax2 = divider2.append_axes("right", size="5%", pad=0. The question is I don't want to share y-axis for the first row of the subplot. Considering my subplot has two rows and five columns, I just want to share x and y axis for the second row, and share the x axis for the first row. Plt.setp(ax2.get_yticklabels(), visible=False) Since I choose sharex'col' and sharey'row', all plots in the subplots share their x and y axis through columns and rows. If you do want to change this at some point all you need to do is to replace plt.subplots_adjust(wspace = -.059) with plt.tight_layout().įrom mpl_toolkits.axes_grid1 import make_axes_locatableĪx1 = fig.add_subplot(1,2,1, aspect = "equal")Īx2 = fig.add_subplot(1,2,2, aspect = "equal", sharey = ax1) #Share y-axes with subplot 1 1 Answer Sorted by: 0 A quick (and possibly very stupid) fix I found is to sort of do the axis sharing manually. Personally I do not like it to have no space between the subplots at all. import matplotlib.pyplot as plt import cartopy.crs as ccrs import cartopy.feature as cfeature proj ccrs.LambertConformal (centrallatitude39,centrallongitude-95, standardparallels (39, 39)) fig plt.figure.

To later turn other subplots' ticklabels on, use tickparams. Similarly, when subplots have a shared y-axis along a row, only the y tick labels of the first column subplot are created. I want to use sharex and sharey to sync zooming and clicking in two subplots. When subplots have a shared x-axis along a column, only the x tick labels of the bottom subplot are created.

MATPLOTLIB SUBPLOT SHARE Y CODE
I created the following code based on your question. Share x and y axis between subplots with map.
