I would consider using the AxesGrid toolkit [1], which makes it very easy
to have a single colorbar for multiple plots.

[1] - http://matplotlib.org/1.3.1/mpl_toolkits/axes_grid/users/overview.html

Thanks,
Alex


On Tue, May 20, 2014 at 8:04 PM, Alex Goodman <alex.good...@colostate.edu>wrote:

> I would consider using the AxesGrid toolkit [1], which makes it very easy
> to have a single colorbar for multiple plots.
>
> [1] -
> http://matplotlib.org/1.3.1/mpl_toolkits/axes_grid/users/overview.html
>
> Thanks,
> Alex
>
>
> On Tue, May 20, 2014 at 7:57 PM, Dyah rahayu martiningrum <
> dyahr...@gmail.com> wrote:
>
>> I am a newbie in python and I try to plot data like below :
>>
>> base_dir = 'C:/DATA2013/Day_E/'
>> nc_fnames = ['20130203.faieb3p4g.nc', 
>> '20130203.faieb3p4g.nc','20130203.faieb3p4g.nc']
>> # beams
>> ibeams = [0,1,2]
>> # Change directory
>> os.chdir(base_dir)
>> for i, fname in enumerate(nc_fnames):
>>
>>    # Open file
>>     fd = nc.Dataset(fname, 'r')
>>
>>     # Read variables
>>     beam = fd.variables['beam'][:]
>>     rng = fd.variables['range'][:]
>>     tim = fd.variables['time'][:]
>>     pwr = fd.variables['pwr'][:]
>>     nfft = fd.variables['nfft'][0]
>>     pn = fd.variables['pnoise'][:]
>>
>>     # Close netCDF file
>>     fd.close()
>>
>>     # Specify beam
>>     ibeam = ibeams[i]
>>
>>     # Time convertion
>>     tim = tim/3600.0
>>
>>     #Plot
>>     p_plot = pwr[ibeam]
>>
>>     for it in range(len(tim)):
>>         p_plot[it] = p_plot[it] - pn[ibeam][it] - 10.*np.log10(nfft)
>>
>>     p_plot = p_plot.transpose()
>> #Specify subplot
>>     pl.subplot(311 + i)#Contour plot
>>     pl.contourf(tim, rng, p_plot)    #Plot colorbar
>>     pl.colorbar()
>> # Set X and Y axis lower/upper limit
>>     set_xy = range(4)
>>     set_xy[0] = 18.0 # x min
>>     set_xy[1] = 30.0 # x max
>>     set_xy[2] = 90.0 # y min
>>     set_xy[3] = 170.0 # y max
>>     pl.axis(set_xy)
>> # Set labels
>> pl.xlabel('time (hours)')
>> pl.ylabel('range (km)')
>>
>> pl.show()
>>
>>
>> The result looks like three panels with different colorbar for each
>> panel. How do I make only one colorbar for all panels? Thank you in advance.
>>
>>
>> ------------------------------------------------------------------------------
>> "Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
>> Instantly run your Selenium tests across 300+ browser/OS combos.
>> Get unparalleled scalability from the best Selenium testing platform
>> available
>> Simple to use. Nothing to install. Get started now for free."
>> http://p.sf.net/sfu/SauceLabs
>> _______________________________________________
>> Matplotlib-users mailing list
>> Matplotlib-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
>>
>
>
> --
> Alex Goodman
> Graduate Research Assistant
> Department of Atmospheric Science
> Colorado State University
>



-- 
Alex Goodman
Graduate Research Assistant
Department of Atmospheric Science
Colorado State University
------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.
Get unparalleled scalability from the best Selenium testing platform available
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to