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

Reply via email to