SourceForge logo
SourceForge logo
Menu

matplotlib-users — Discussion related to using matplotlib

You can subscribe to this list here.

2003 Jan
Feb
Mar
Apr
May
(3)
Jun
Jul
Aug
(12)
Sep
(12)
Oct
(56)
Nov
(65)
Dec
(37)
2004 Jan
(59)
Feb
(78)
Mar
(153)
Apr
(205)
May
(184)
Jun
(123)
Jul
(171)
Aug
(156)
Sep
(190)
Oct
(120)
Nov
(154)
Dec
(223)
2005 Jan
(184)
Feb
(267)
Mar
(214)
Apr
(286)
May
(320)
Jun
(299)
Jul
(348)
Aug
(283)
Sep
(355)
Oct
(293)
Nov
(232)
Dec
(203)
2006 Jan
(352)
Feb
(358)
Mar
(403)
Apr
(313)
May
(165)
Jun
(281)
Jul
(316)
Aug
(228)
Sep
(279)
Oct
(243)
Nov
(315)
Dec
(345)
2007 Jan
(260)
Feb
(323)
Mar
(340)
Apr
(319)
May
(290)
Jun
(296)
Jul
(221)
Aug
(292)
Sep
(242)
Oct
(248)
Nov
(242)
Dec
(332)
2008 Jan
(312)
Feb
(359)
Mar
(454)
Apr
(287)
May
(340)
Jun
(450)
Jul
(403)
Aug
(324)
Sep
(349)
Oct
(385)
Nov
(363)
Dec
(437)
2009 Jan
(500)
Feb
(301)
Mar
(409)
Apr
(486)
May
(545)
Jun
(391)
Jul
(518)
Aug
(497)
Sep
(492)
Oct
(429)
Nov
(357)
Dec
(310)
2010 Jan
(371)
Feb
(657)
Mar
(519)
Apr
(432)
May
(312)
Jun
(416)
Jul
(477)
Aug
(386)
Sep
(419)
Oct
(435)
Nov
(320)
Dec
(202)
2011 Jan
(321)
Feb
(413)
Mar
(299)
Apr
(215)
May
(284)
Jun
(203)
Jul
(207)
Aug
(314)
Sep
(321)
Oct
(259)
Nov
(347)
Dec
(209)
2012 Jan
(322)
Feb
(414)
Mar
(377)
Apr
(179)
May
(173)
Jun
(234)
Jul
(295)
Aug
(239)
Sep
(276)
Oct
(355)
Nov
(144)
Dec
(108)
2013 Jan
(170)
Feb
(89)
Mar
(204)
Apr
(133)
May
(142)
Jun
(89)
Jul
(160)
Aug
(180)
Sep
(69)
Oct
(136)
Nov
(83)
Dec
(32)
2014 Jan
(71)
Feb
(90)
Mar
(161)
Apr
(117)
May
(78)
Jun
(94)
Jul
(60)
Aug
(83)
Sep
(102)
Oct
(132)
Nov
(154)
Dec
(96)
2015 Jan
(45)
Feb
(138)
Mar
(176)
Apr
(132)
May
(119)
Jun
(124)
Jul
(77)
Aug
(31)
Sep
(34)
Oct
(22)
Nov
(23)
Dec
(9)
2016 Jan
(26)
Feb
(17)
Mar
(10)
Apr
(8)
May
(4)
Jun
(8)
Jul
(6)
Aug
(5)
Sep
(9)
Oct
(4)
Nov
Dec
2017 Jan
(5)
Feb
(7)
Mar
(1)
Apr
(5)
May
Jun
(3)
Jul
(6)
Aug
(1)
Sep
Oct
(2)
Nov
(1)
Dec
2018 Jan
Feb
Mar
Apr
(1)
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
2020 Jan
Feb
Mar
Apr
May
(1)
Jun
Jul
Aug
Sep
Oct
Nov
Dec
2025 Jan
(1)
Feb
Mar
Apr
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
S M T W T F S





1
(2)
2
(6)
3
4
(7)
5
(10)
6
(4)
7
(17)
8
(4)
9
(1)
10
(1)
11
(19)
12
(14)
13
(8)
14
(14)
15
(9)
16
(1)
17
18
19
(8)
20
(5)
21
(7)
22
(13)
23
(1)
24
25
(4)
26
(2)
27
(17)
28
(13)
29
(6)
30
(6)
31
(5)






Showing 6 results of 6

From: Sudheer J. <sud...@ya...> - 2013年03月02日 11:35:44
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 <pel...@gm...>
To: "Mat...@li..." <mat...@li...> 
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:
importiris
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
Hope that helps!
Phil
On 2 March 2013 09:37, Phil Elson <pel...@gm...> 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
Mat...@li...
https://lists.sourceforge.net/lists/listinfo/matplotlib-users 
From: Sudheer J. <sud...@ya...> - 2013年03月02日 10:53:49
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(R),Tel:+91-40-9440832534(Mobile)
E-mail:sjo...@gm...;sud...@ya...
Web- http://oppamthadathil.tripod.com
***************************************************************
________________________________
 From: Phil Elson <pel...@gm...>
To: "Mat...@li..." <mat...@li...> 
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
Mat...@li...
https://lists.sourceforge.net/lists/listinfo/matplotlib-users 
From: Phil E. <pel...@gm...> - 2013年03月02日 10:10:19
Attachments: 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
[image: Inline images 1]
Hope that helps!
Phil
On 2 March 2013 09:37, Phil Elson <pel...@gm...> 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
>
>
>
From: Phil E. <pel...@gm...> - 2013年03月02日 09:37:27
Attachments: figure_1.png
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
From: Sudheer J. <sud...@ya...> - 2013年03月02日 06:20:21
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(R),Tel:+91-40-9440832534(Mobile)
E-mail:sjo...@gm...;sud...@ya...
Web- http://oppamthadathil.tripod.com
***************************************************************
From: Sudheer J. <sud...@ya...> - 2013年03月02日 01:08:34
Thank you Pierre.
 with best regards,
Sudheer
From: Pierre Haessig <pie...@cr...>
To: 
Cc: "mat...@li..." <mat...@li...> 
Sent: Thursday, 28 February 2013 7:15 PM
Subject: Re: [Matplotlib-users] cross correlation
 
Hi,
Le 27/02/2013 10:01, Sudheer Joseph a écrit :
> I was checking the plt.xcorr and it calls the np.correlate in side it.
> It calls np.correlate(ts1,ts2, mode=2).
Just as a side note, mode=2 is the old fashioned way to specify
mode='full' [1]. This may help in reading the numpy.correlate doc.
This being said, I'm really unfamiliar with cross-correlations. I just
kind of know the usual 95% confidence interval for autocorrelation at
1.96/sqrt(n). Just as a quick check, this is what R uses by default, but
there are options like ci.type get more appropriate intervals for an MA
series
(http://stat.ethz.ch/R-manual/R-patched/library/stats/html/plot.acf.html)
best,
Pierre
[1] https://github.com/numpy/numpy/blob/master/numpy/core/numeric.py#L678
------------------------------------------------------------------------------
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
Mat...@li...
https://lists.sourceforge.net/lists/listinfo/matplotlib-users 

Showing 6 results of 6

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /