depth longitude plot

Dear Users,

                         I am trying to make  vertical section plot along equator of Indian ocean from 45E to 100E and latitude 0.

from levitus climatology using below code. What is the best and simple way to achieve this? np.meshgrid allows only 2 variables so I am not able to make x,y,z= using np.meshgrid(lat,depth,temp)

how to go about this? Is there a set of codes for handling such graphs?

url=‘http://www.marine.csiro.au/dods/nph-dods/dods-data/climatology-netcdf/levitus_monthly_temp_98.nc

import cdms2

from matplotlib import pyplot as plt

from netCDF4 import Dataset as ncd

f=cdms2.open(url)

f.variables()

x=f.getAxis(‘lon’)

y=f.getAxis(‘lat’)

z=f.getAxis(‘z’)

depth=z.getData()

lat=y.getData()

lon=x.getData()

temp=f(‘TEMP’)

lonmin=np.where(lon==45)

lonmax=np.where(lon==100)

nlon=lon[lonmin:lonmax]

lat0=np.where(lat==0.5)

ntemp=temp[:,lat0,lonmin:lonmax]

basically I wanted to make a plot plt.plot(nlon,depth,ntemp)

Please help.

with best regards,

Sudheer

···

Sudheer Joseph
Indian National Centre for Ocean Information Services
Ministry of Earth Sciences, Govt. of India
POST BOX NO: 21, IDA Jeedeemetla P.O.
Via Pragathi Nagar,Kukatpally, Hyderabad; Pin:5000 55
Tel:+91-40-23886047(O),Fax:+91-40-23895011(O),
Tel:+91-40-23044600®,Tel:+91-40-9440832534(Mobile)
E-mail:sjo.India@…287…;sudheer.joseph@…9…
Web- http://oppamthadathil.tripod.com


Perhaps something like:

from matplotlib import pyplot as plt

from netCDF4 import Dataset

import numpy as np

url=*'
http://www.marine.csiro.au/dods/nph-dods/dods-data/climatology-netcdf/levitus_monthly_temp_98.nc
'*

ds = Dataset(url)

temp = ds.variables[*'TEMP'*]

lats = ds.variables[*'**lat**'*]

lons = ds.variables[*'**lon**'*]

depths = ds.variables[*'z'*]

# filter all but one latitude

lat_index = np.where(lats[:] == 0.5)[0][0]

lats = lats[lat_index]

# filter a range of longitudes

lon_lower_index = np.where(lons[:] == 44.5)[0][0]

lon_upper_index = np.where(lons[:] == 100.5)[0][0]

lons = lons[lon_lower_index:lon_upper_index]

temp = temp[0, :, lat_index, lon_lower_index:lon_upper_index]

plt.pcolormesh(lons, depths[:], temp)

plt.gca().invert_yaxis()

plt.show()

The indexing approach used here is quite flakey, so I certainly wouldn't
use this in anything operational.

Hope this helps,

Phil

figure_1.png

Incidentally, if you wanted to do this a little more expressively than indexing, you could look into using iris (http://scitools.org.uk/iris/docs/latest/index.html). It doesn’t currently support DAP, but if you had the NetCDF file (from http://www.marine.csiro.au/dods-data/climatology-netcdf/levitus_monthly_temp_98.nc) you would do:

import iris

import iris.quickplot as qplt

import matplotlib.pyplot as plt

temp_cube = iris.load_cube(‘levitus_monthly_temp_98.nc)

Sort out some of the bad metadata. Firstly, set the unit,

secondly rename the dimension 1 coordinate to ‘depth’.

temp_cube.unit = ‘C’

temp_cube.coord(dimensions=1, dim_coords=True).rename(‘depth’)

Extract a spatial sub-domain.

sub_temp_cube = temp_cube.extract(iris.Constraint(latitude=0.5,

longitude=lambda v: 45 < v < 100))

Iterate over all the depth-longitude sections (in this case it

iterates over time)

for cross_sect_cube in sub_temp_cube.slices([‘depth’, ‘longitude’]):

qplt.pcolormesh(cross_sect_cube)

plt.gca().invert_yaxis()

plt.show()

break

figure_1.png

Hope that helps!

Phil

···

On 2 March 2013 09:37, Phil Elson <pelson.pub@…287…> wrote:

Perhaps something like:

from matplotlib import pyplot as plt

from netCDF4 import Dataset

import numpy as np

url=http://www.marine.csiro.au/dods/nph-dods/dods-data/climatology-netcdf/levitus_monthly_temp_98.nc

ds = Dataset(url)

temp = ds.variables[‘TEMP’]

lats = ds.variables[lat]

lons = ds.variables[lon]

depths = ds.variables[‘z’]

filter all but one latitude

lat_index = np.where(lats[:] == 0.5)[0][0]

lats = lats[lat_index]

filter a range of longitudes

lon_lower_index = np.where(lons[:] == 44.5)[0][0]

lon_upper_index = np.where(lons[:] == 100.5)[0][0]

lons = lons[lon_lower_index:lon_upper_index]

temp = temp[0, :, lat_index, lon_lower_index:lon_upper_index]

plt.pcolormesh(lons, depths[:], temp)

plt.gca().invert_yaxis()

plt.show()

The indexing approach used here is quite flakey, so I certainly wouldn’t use this in anything operational.

Hope this helps,

Phil

Tank you very much for both solutions Phil,

with best regards,

Sudheer

···

Sudheer Joseph
Indian National Centre for Ocean Information Services
Ministry of Earth Sciences, Govt. of India
POST BOX NO: 21, IDA Jeedeemetla P.O.
Via Pragathi Nagar,Kukatpally, Hyderabad; Pin:5000 55
Tel:+91-40-23886047(O),Fax:+91-40-23895011(O),
Tel:+91-40-23044600®,Tel:+91-40-9440832534(Mobile)
E-mail:sjo.India@…287…;sudheer.joseph@…9…
Web- http://oppamthadathil.tripod.com



From: Phil Elson <pelson.pub@…287…>
To: "Matplotlib-users@lists.sourceforge.net" matplotlib-users@lists.sourceforge.net
Sent: Saturday, 2 March 2013 3:07 PM
Subject: Re: [Matplotlib-users] depth longitude plot

Perhaps something like:

from matplotlib import pyplot as plt

from netCDF4 import Dataset

import numpy as np

url=http://www.marine.csiro.au/dods/nph-dods/dods-data/climatology-netcdf/levitus_monthly_temp_98.nc

ds = Dataset(url)

temp = ds.variables[‘TEMP’]

lats = ds.variables[lat]

lons = ds.variables[lon]

depths = ds.variables[‘z’]

filter all but one latitude

lat_index = np.where(lats[:] == 0.5)[0][0]

lats = lats[lat_index]

filter a range of longitudes

lon_lower_index = np.where(lons[:] == 44.5)[0][0]

lon_upper_index = np.where(lons[:] == 100.5)[0][0]

lons = lons[lon_lower_index:lon_upper_index]

temp = temp[0, :, lat_index, lon_lower_index:lon_upper_index]

plt.pcolormesh(lons, depths[:], temp)

plt.gca().invert_yaxis()

plt.show()

The indexing approach used here is quite flakey, so I certainly wouldn’t use this in anything operational.

Hope this helps,

Phil


Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb


Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Hi Phil,

Though iris looked to be promising it needed many other libraries, so I chose the below suggestion. But is there a way to overlay contours on this ? also is it possible to specify the levels?

In [23]: plt.pcolormesh?? did not give much help

with best regards,

Sudheer

···

From: Phil Elson <pelson.pub@…287…>
To: “Matplotlib-users@…1220…sts.sourceforge.net” matplotlib-users@lists.sourceforge.net
Sent: Saturday, 2 March 2013 3:40 PM
Subject: Re: [Matplotlib-users]
depth longitude plot

Incidentally, if you wanted to do this a little more expressively than indexing, you could look into using iris (http://scitools.org.uk/iris/docs/latest/index.html). It doesn’t currently support DAP, but if you had the NetCDF file (from http://www.marine.csiro.au/dods-data/climatology-netcdf/levitus_monthly_temp_98.nc) you would do:

import iris

import iris.quickplot as qplt

import matplotlib.pyplot as plt

temp_cube = iris.load_cube(‘levitus_monthly_temp_98.nc)

Sort out some of the bad metadata. Firstly, set the unit,

secondly rename the dimension 1 coordinate to ‘depth’.

temp_cube.unit = ‘C’

temp_cube.coord(dimensions=1, dim_coords=True).rename(‘depth’)

Extract a spatial sub-domain.

sub_temp_cube = temp_cube.extract(iris.Constraint(latitude=0.5,

longitude=lambda v: 45 < v < 100))

Iterate over all the depth-longitude sections (in this case it

iterates over time)

for cross_sect_cube in sub_temp_cube.slices([‘depth’, ‘longitude’]):

qplt.pcolormesh(cross_sect_cube)

plt.gca().invert_yaxis()

plt.show()

break

Inline images 1

Hope that helps!

Phil

On 2 March 2013 09:37, Phil Elson <pelson.pub@…287…> wrote:

Perhaps something like:

from matplotlib import pyplot as plt

from netCDF4 import Dataset

import numpy as np

url=http://www.marine.csiro.au/dods/nph-dods/dods-data/climatology-netcdf/levitus_monthly_temp_98.nc

ds = Dataset(url)

temp = ds.variables[‘TEMP’]

lats = ds.variables[lat]

lons = ds.variables[lon]

depths = ds.variables[‘z’]

filter all but one latitude

lat_index = np.where(lats[:] == 0.5)[0][0]

lats = lats[lat_index]

filter a range of longitudes

lon_lower_index = np.where(lons[:] == 44.5)[0][0]

lon_upper_index = np.where(lons[:] == 100.5)[0][0]

lons = lons[lon_lower_index:lon_upper_index]

temp = temp[0, :, lat_index, lon_lower_index:lon_upper_index]

plt.pcolormesh(lons, depths[:], temp)

plt.gca().invert_yaxis()

plt.show()

The indexing approach used here is quite flakey, so I certainly wouldn’t use this in anything operational.

Hope this helps,

Phil


Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb


Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

You can overlay contours on the pcolormesh image by simply using the plt.contour() function after the pcolormesh() call. It allows you to control which levels to contour and you can specify the attributes of those contours like the color or thickness. Note that unlike Matlab, you don’t have to call “hold on” between plots. By default, matplotlib will hold.

I hope that helps!
Ben Root

···

On Sat, Mar 2, 2013 at 6:35 AM, Sudheer Joseph <sudheer.joseph@…9…> wrote:

Hi Phil,

Though iris looked to be promising it needed many other libraries, so I chose the below suggestion. But is there a way to overlay contours on this ? also is it possible to specify the levels?

In [23]: plt.pcolormesh?? did not give much help

with best regards,

Sudheer

Thank you,

                   I just posted this question in numpy lists thinking that it is possible after regriding the data to new axes. 

Thanks for the help.

with best
regards,

Sudheer

···

Sudheer Joseph
Indian National Centre for Ocean Information Services
Ministry of Earth Sciences, Govt. of India
POST BOX NO: 21, IDA Jeedeemetla P.O.
Via Pragathi Nagar,Kukatpally, Hyderabad; Pin:5000
55
Tel:+91-40-23886047(O),Fax:+91-40-23895011(O),
Tel:+91-40-23044600(R),Tel:+91-40-9440832534(Mobile)
E-mail:sjo.India@…287…;sudheer.joseph@…9…
Web- http://oppamthadathil.tripod.com



From: Benjamin Root <ben.root@…1304…>
To: Sudheer Joseph <sudheer.joseph@…9…>
Cc: Phil Elson <pelson.pub@…287…>; “Matplotlib-users@lists.sourceforge.net” <matplotlib-users@…813…ourceforge.net>
Sent: Monday, 4
March 2013 7:53 PM
Subject: Re: [Matplotlib-users] depth longitude plot

On Sat, Mar 2, 2013 at 6:35 AM, Sudheer Joseph <sudheer.joseph@…9…> wrote:

Hi Phil,

Though iris looked to be promising it needed many other libraries, so I chose the below suggestion. But is there a way to overlay contours on this ? also is it possible to specify the levels?

In [23]: plt.pcolormesh?? did not give much help

with best regards,

Sudheer

You can overlay contours on the pcolormesh image by simply using the plt.contour() function after the pcolormesh() call. It allows you to control which levels to contour and you can specify the attributes of those contours like the color or thickness. Note that unlike Matlab, you don’t have to call “hold on” between plots. By default, matplotlib will hold.

I hope that helps!
Ben Root

Hi Benamin,

I was looking for a plot similar to the attached one named ferret.gif. But from matplot lib I get flat fill and contours which are not aligned to the levels ( named figure_1.png , it looks like matplotlib has just flat surfaces as it used pcolor.

with best regards,

Sudheer

···

From: Sudheer Joseph <sudheer.joseph@…9…>

To: Benjamin Root <ben.root@…1304…>
Cc:Matplotlib-users@lists.sourceforge.netmatplotlib-users@lists.sourceforge.net
Sent: Monday, 4 March 2013 8:19 PM
Subject: Re: [Matplotlib-users] depth longitude plot

Thank you,

                   I just posted this question in numpy lists thinking that it is possible after regriding the data to new axes. 

Thanks for the help.

with best
regards,

Sudheer


Sudheer Joseph
Indian National Centre for Ocean Information Services
Ministry of Earth Sciences, Govt. of India
POST BOX NO: 21, IDA Jeedeemetla P.O.
Via Pragathi Nagar,Kukatpally, Hyderabad; Pin:5000
55
Tel:+91-40-23886047(O),Fax:+91-40-23895011(O),
Tel:+91-40-23044600(R),Tel:+91-40-9440832534(Mobile)
E-mail:sjo.India@…287…;sudheer.joseph@…9…
Web- http://oppamthadathil.tripod.com



From: Benjamin Root <ben.root@…1304…>
To: Sudheer Joseph <sudheer.joseph@…9…>
Cc: Phil Elson <pelson.pub@…287…>; “Matplotlib-users@lists.sourceforge.net” <matplotlib-users@…2018…rceforge.net>
Sent: Monday, 4
March 2013 7:53 PM
Subject: Re: [Matplotlib-users] depth longitude plot

On Sat, Mar 2, 2013 at 6:35 AM, Sudheer Joseph <sudheer.joseph@…9…> wrote:

Hi Phil,

Though iris looked to be promising it needed many other libraries, so I chose the below suggestion. But is there a way to overlay contours on this ? also is it possible to specify the levels?

In [23]: plt.pcolormesh?? did not give much help

with best regards,

Sudheer

You can overlay contours on the pcolormesh image by simply using the plt.contour() function after the pcolormesh() call. It allows you to control which levels to contour and you can specify the attributes of those contours like the color or thickness. Note that unlike Matlab, you don’t have to call “hold on” between plots. By default, matplotlib will hold.

I hope that helps!
Ben Root


Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb


Matplotlib-users mailing list
Matplotlib-users@…813…ourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Hi Sudheer,

You want contourf.

http://matplotlib.org/examples/pylab_examples/contour_image.html

Cheers, Jody

···

On Mar 4, 2013, at 9:04 AM, Sudheer Joseph <sudheer.joseph@…9…> wrote:

Hi Benamin,

I was looking for a plot similar to the attached one named ferret.gif. But from matplot lib I get flat fill and contours which are not aligned to the levels ( named figure_1.png , it looks like matplotlib has just flat surfaces as it used pcolor.

with best regards,

Sudheer

From: Sudheer Joseph <sudheer.joseph@…9…>

To: Benjamin Root <ben.root@…3421…>
Cc: “Matplotlib-users@…1735…sourceforge.net” matplotlib-users@lists.sourceforge.net
Sent: Monday, 4 March 2013 8:19 PM
Subject: Re: [Matplotlib-users] depth longitude plot

Thank you,

                   I just posted this question in numpy lists thinking that it is possible after regriding the data to new axes. 

Thanks for the help.

with best
regards,

Sudheer


Sudheer Joseph
Indian National Centre for Ocean Information Services
Ministry of Earth Sciences, Govt. of India
POST BOX NO: 21, IDA Jeedeemetla P.O.
Via Pragathi Nagar,Kukatpally, Hyderabad; Pin:5000
55
Tel:+91-40-23886047(O),Fax:+91-40-23895011(O),
Tel:+91-40-23044600(R),Tel:+91-40-9440832534(Mobile)
E-mail:sjo.India@gmail.com;sudheer.joseph@…9…
Web- http://oppamthadathil.tripod.com



From: Benjamin Root <ben.root@…1304…>
To: Sudheer Joseph <sudheer.joseph@…9…>
Cc: Phil Elson <pelson.pub@…287…>; “Matplotlib-users@lists.sourceforge.net” <matplotlib-users@…1867…s.sourceforge.net>
Sent: Monday, 4
March 2013 7:53 PM
Subject: Re: [Matplotlib-users] depth longitude plot

On Sat, Mar 2, 2013 at 6:35 AM, Sudheer Joseph <sudheer.joseph@…9…> wrote:

Hi Phil,

Though iris looked to be promising it needed many other libraries, so I chose the below suggestion. But is there a way to overlay contours on this ? also is it possible to specify the levels?

In [23]: plt.pcolormesh?? did not give much help

with best regards,

Sudheer

You can overlay contours on the pcolormesh image by simply using the plt.contour() function after the pcolormesh() call. It allows you to control which levels to contour and you can specify the attributes of those contours like the color or thickness. Note that unlike Matlab, you don’t have to call “hold on” between plots. By default, matplotlib will hold.

I hope that helps!
Ben Root


Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb


Matplotlib-users mailing list
Matplotlib-users@…1543…rge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

<ferret.gif><figure_1.png>------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

Jody Klymak

http://web.uvic.ca/~jklymak/

Thanks to all Matplotlib experts for extending help,

With the suggestions I could make the script work and I am close to the target I had in mind,

Below script produces as depth longitude contou-filled plot.

However I have below concerns,

  1. There is a wide gap between label and the contours ie it appears like ------ 2.4 … is there a way to reduce this gap?

  2. The labels are appearing cluttered at about 100m depth though they culd have spread apart at each level. Is there a way to control their placing to avoid cluttering?

  3. Is there a way to make the longitude as in case of maps ie can the x axis labels be 50E 60E … 90E

I am not sure if I am too much ambitious with
regard to matplotlib, but I was using ferret where it takes care of the labeling.

with best regards,

Sudheer

from matplotlib import pyplot as plt

from netCDF4 import Dataset

import numpy as np

url=‘http://www.marine.csiro.au/dods/nph-dods/dods-data/climatology-netcdf/levitus_monthly_temp_98.nc

ds = Dataset(url)

temp = ds.variables[‘TEMP’]

lats = ds.variables[‘lat’]

lons =
ds.variables[‘lon’]

depths = ds.variables[‘z’]

filter depths

dmin = np.where(depths[:] == 0.)[0][0]

dmax = np.where(depths[:] == 1000)[0][0]

filter all but one latitude

lat_index = np.where(lats[:] == 0.5)[0][0]

lats = lats[lat_index]

filter a range of longitudes

lon_lower_index = np.where(lons[:] == 44.5)[0][0]

lon_upper_index = np.where(lons[:] == 95.5)[0][0]

lons = lons[lon_lower_index:lon_upper_index]

depths=depths[dmin:dmax]

temp = temp[0,dmin:dmax, lat_index, lon_lower_index:lon_upper_index]

#plt.pcolormesh(lons,depths, temp)

nx,ny=np.meshgrid(lons,depths)

clevs=np.arange(temp.min(),temp.max()+2,temp.std()/5)

norm = plt.cm.colors.Normalize(vmax=abs(temp).max(), vmin=-abs(temp).max())

cmap =
plt.cm.gist_rainbow_r

plt.figure()

cs1=plt.contourf(nx,ny,temp, clevs,cmap=plt.cm.get_cmap(cmap, len(clevs)-1))

cs2=plt.contour(nx,ny,temp, cs1.levels,colors = ‘k’,linewidth=2,hold=‘on’)

plt.clabel(cs2,inline=True, fmt=‘%1.1f’, fontsize=18)

cb = plt.colorbar(cs1,pad=.02) #(location=‘right’)#,size=“5%”, pad=‘2%’)

plt.gca().invert_yaxis()

plt.show()

···

Sudheer Joseph
Indian National Centre for Ocean Information Services
Ministry of Earth Sciences, Govt. of India
POST BOX NO: 21, IDA Jeedeemetla
P.O.
Via Pragathi Nagar,Kukatpally, Hyderabad; Pin:5000 55
Tel:+91-40-23886047(O),Fax:+91-40-23895011(O),
Tel:+91-40-23044600(R),Tel:+91-40-9440832534(Mobile)
E-mail:sjo.India@…287…;sudheer.joseph@…9…
Web- http://oppamthadathil.tripod.com



From: Jody Klymak <jklymak@…1686…2…>
To: Sudheer Joseph <sudheer.joseph@…9…>
Cc:Matplotlib-users@lists.sourceforge.netmatplotlib-users@lists.sourceforge.net
Sent: Tuesday, 5 March 2013 2:10 AM
Subject: Re: [Matplotlib-users] depth longitude plot

Hi Sudheer,

You want contourf.

http://matplotlib.org/examples/pylab_examples/contour_image.html

Cheers, Jody

On Mar 4, 2013, at 9:04 AM, Sudheer Joseph <sudheer.joseph@…9…> wrote:

Hi Benamin,

I was looking for a plot similar to the attached one named ferret.gif. But from matplot lib I get flat fill and contours which are not aligned to the levels ( named figure_1.png , it looks like matplotlib has just flat surfaces as it used pcolor.

with best regards,

Sudheer

From: Sudheer Joseph <sudheer.joseph@…9…>

To: Benjamin Root <ben.root@…1304…>
Cc:Matplotlib-users@lists.sourceforge.net” <matplotlib-users@…1738…net>
Sent: Monday, 4 March 2013 8:19 PM
Subject: Re: [Matplotlib-users] depth longitude plot

Thank
you,

                   I just posted this question in numpy lists thinking that it is possible after regriding the data to new axes. 

Thanks for the help.

with best
regards,

Sudheer


Sudheer Joseph
Indian National Centre for Ocean Information Services
Ministry of Earth Sciences, Govt. of India
POST BOX NO: 21, IDA Jeedeemetla P.O.
Via Pragathi Nagar,Kukatpally, Hyderabad; Pin:5000
55
Tel:+91-40-23886047(O),Fax:+91-40-23895011(O),
Tel:+91-40-23044600(R),Tel:+91-40-9440832534(Mobile)
E-mail:sjo.India@gmail.com;sudheer.joseph@…9…
Web- http://oppamthadathil.tripod.com



From: Benjamin Root <ben.root@…1304…>
To: Sudheer Joseph <sudheer.joseph@…9…>
Cc: Phil Elson <pelson.pub@…287…>; “Matplotlib-users@lists.sourceforge.netmatplotlib-users@lists.sourceforge.net
Sent: Monday, 4
March 2013 7:53 PM
Subject: Re: [Matplotlib-users] depth longitude plot

On Sat, Mar 2, 2013 at 6:35 AM, Sudheer Joseph <sudheer.joseph@…9…> wrote:

Hi Phil,

Though iris looked to be promising it needed many other libraries, so I chose the below suggestion. But is there a way to overlay contours on this ? also is it possible to specify the levels?

In [23]: plt.pcolormesh?? did not give much help

with best regards,

Sudheer

You can overlay contours on the pcolormesh image by simply using the plt.contour() function after the pcolormesh() call. It allows you to control which levels to contour and you can specify the attributes of those contours like the color or thickness. Note that unlike Matlab, you don’t have to call “hold on” between plots. By default, matplotlib will hold.

I hope that helps!
Ben Root


Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb


Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

<ferret.gif><figure_1.png>------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

Jody Klymak

http://web.uvic.ca/~jklymak/

Thanks to all Matplotlib experts for extending help,

With the suggestions I could make the script work and I am close to the target I had in mind,

Below script produces as depth longitude contou-filled plot.

However I have below concerns,

  1. There is a wide gap between label and the contours ie it appears like ------ 2.4 … is there a way to reduce this gap?

Try inline=False for the clabel call, but that might over-do it.

  1. The labels are appearing cluttered at about 100m depth though they culd have spread apart at each level. Is there a way to control their placing to avoid cluttering?

This has been a long-standing issue with matplotlib. There has been improvements, but it still isn’t perfect. I am not familiar with some of the newer tricks that are available.

  1. Is there a way to make the longitude as in case of maps ie can the x axis labels be 50E 60E … 90E

You can set the tick formatter. Here is one example of how to do it.

http://matplotlib.org/examples/pylab_examples/custom_ticker1.html

I hope that helps!
Ben Root

···

On Mon, Mar 4, 2013 at 8:26 PM, Sudheer Joseph <sudheer.joseph@…9…> wrote:

Thank you,

  1. There is a wide gap between label and the contours ie it appears like ------ 2.4 … is there a way to reduce this gap?

Try inline=False for the clabel call, but that might over-do it.

I tried this but it totally removes the space, the inline_space=n do not appear to take the given value and it works always with default value…

  1. The labels are appearing cluttered at about 100m depth though they culd have spread apart at each level. Is there a way to control their placing to avoid cluttering?

This has been a long-standing issue with matplotlib. There has been improvements, but it still isn’t perfect. I am not familiar with some of the newer tricks that are available.
Hope some one tried those will respond!

  1. Is there a way to make the longitude as in case of maps ie can the x axis labels be 50E 60E … 90E

You can set the tick formatter. Here is one example of how to do it.

http://matplotlib.org/examples/pylab_examples/custom_ticker1.html

Thank you

I hope that helps!
Ben Root