<div dir="ltr">Another approach that I like is to use: <a href="https://matplotlib.org/examples/axes_grid/demo_axes_grid.html">https://matplotlib.org/examples/axes_grid/demo_axes_grid.html</a><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Aug 5, 2017 at 1:05 PM, Klymak Jody <span dir="ltr"><<a href="mailto:jklymak@uvic.ca" target="_blank">jklymak@uvic.ca</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I modified matplotlib to let you do this by passing an array of axes to the ax argument of colorbar.  It's in the git master branch but that has other bugs so you may not want to use it yet.<br>
<br>
But the way to do this with older releases is to make the axis you want to put the colorbar in manually (cbax=fig.add_axes) with the correct position and then pass cbax to colorbar as the argument to the parameter cax.  Of course you may need to make the other subplots smaller prob using the subplots_adjust method if the figure.<br>
<br>
Cheers.  Jody<br>
<br>
<br>
<br>
Sent from my iPhone<br>
<div class="HOEnZb"><div class="h5"><br>
> On Jul 19, 2017, at 07:31, danjames95 <<a href="mailto:danjames95@live.co.uk">danjames95@live.co.uk</a>> wrote:<br>
><br>
> Hi,<br>
><br>
> I am trying to plot 4 subplots in a 2 by 2 grid for mean sea level pressure<br>
> data over the four seasons.<br>
><br>
> I have managed to plot all four in the same figure with their own individual<br>
> colorbars, however, I would ideally like the figure to display one colorbar<br>
> at the bottom to represent all four figures and I have been unsuccessful in<br>
> doing this so far. There have been a few posts on this but as this is my<br>
> first assignment (i'm a student at university) with python, I'm struggling<br>
> to understand the answers!<br>
><br>
> The section of my code which involves the plotting of data is as follows:<br>
><br>
> ...<br>
> #Select Projection<br>
> lon_0= 0<br>
> lat_0=lats.mean()<br>
><br>
> m = Basemap(projection = 'cyl', lat_0=lat_0, lon_0=lon_0, resolution = 'l')<br>
> #Convert Lons and Lats<br>
> x,y = np.meshgrid (lons_shifted,lats)<br>
> xx,yy= m(x,y)<br>
><br>
> v = np.linspace(980, 1030, 11, endpoint=True)<br>
><br>
> fig = plt.figure()<br>
><br>
> plt.subplot(2, 2, 1)<br>
> set1 = m.contourf(xx,yy,MSLP_WINTER, v)<br>
> m.drawmapboundary()<br>
> m.drawcoastlines()<br>
> plt.title('Winter')<br>
> bar = plt.colorbar(orientation = 'horizontal', ticks = v, format = '%.0f')<br>
> plt.xlim(-80,20)<br>
> plt.ylim (20,70)<br>
><br>
> plt.subplot(2, 2, 2)<br>
> set2 = m.contourf(xx,yy,MSLP_SPRING, v)<br>
> m.drawmapboundary()<br>
> m.drawcoastlines()<br>
> plt.title('Spring')<br>
> bar = plt.colorbar(orientation = 'horizontal', ticks = v)<br>
> plt.xlim(-80,20)<br>
> plt.ylim (20,70)<br>
><br>
> plt.subplot(2, 2, 3)<br>
> set3 = m.contourf(xx,yy,MSLP_SUMMER, v)<br>
> m.drawmapboundary()<br>
> m.drawcoastlines()<br>
> plt.title('Summer')<br>
> bar = plt.colorbar(orientation = 'horizontal', ticks = v)<br>
> plt.xlim(-80,20)<br>
> plt.ylim (20,70)<br>
><br>
> plt.subplot(2, 2, 4)<br>
> set4 = m.contourf(xx,yy,MSLP_AUTUMN, v)<br>
> m.drawmapboundary()<br>
> m.drawcoastlines()<br>
> plt.title('Autumn')<br>
> bar = plt.colorbar(orientation = 'horizontal', ticks = v)<br>
> plt.xlim(-80,20)<br>
> plt.ylim (20,70)<br>
><br>
> plt.suptitle("Seasonally Averaged Mean Sea Level Pressure between 2006 to<br>
> 2016")<br>
><br>
> plt.show()<br>
><br>
> This creates the following image:<br>
> <<a href="http://matplotlib.1069221.n5.nabble.com/file/n48091/MSLP_Seasonal_Averages.png" rel="noreferrer" target="_blank">http://matplotlib.1069221.n5.<wbr>nabble.com/file/n48091/MSLP_<wbr>Seasonal_Averages.png</a>><br>
><br>
> Any help would be very much appreciated.<br>
> Also, if there any obvious bad habits within this code, please feel free to<br>
> point them out!<br>
><br>
> Thanks,<br>
> Dan<br>
><br>
><br>
><br>
> --<br>
> View this message in context: <a href="http://matplotlib.1069221.n5.nabble.com/Single-Colorbar-for-multiple-subplots-tp48091.html" rel="noreferrer" target="_blank">http://matplotlib.1069221.n5.<wbr>nabble.com/Single-Colorbar-<wbr>for-multiple-subplots-tp48091.<wbr>html</a><br>
> Sent from the matplotlib - users mailing list archive at Nabble.com.<br>
> ______________________________<wbr>_________________<br>
> Matplotlib-users mailing list<br>
> <a href="mailto:Matplotlib-users@python.org">Matplotlib-users@python.org</a><br>
> <a href="https://mail.python.org/mailman/listinfo/matplotlib-users" rel="noreferrer" target="_blank">https://mail.python.org/<wbr>mailman/listinfo/matplotlib-<wbr>users</a><br>
<br>
______________________________<wbr>_________________<br>
Matplotlib-users mailing list<br>
<a href="mailto:Matplotlib-users@python.org">Matplotlib-users@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/matplotlib-users" rel="noreferrer" target="_blank">https://mail.python.org/<wbr>mailman/listinfo/matplotlib-<wbr>users</a><br>
</div></div></blockquote></div><br></div>