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
(35)
2
(29)
3
(12)
4
5
(8)
6
(5)
7
(3)
8
(38)
9
(15)
10
(20)
11
(14)
12
(12)
13
(17)
14
(6)
15
(41)
16
(38)
17
(31)
18
(7)
19
(14)
20
(12)
21
(3)
22
(3)
23
(15)
24
(4)
25
26
(3)
27
(2)
28
(7)
29
(16)
30
(17)
31
(10)



Showing results of 432

<< < 1 2 3 4 5 .. 18 > >> (Page 3 of 18)
From: John H. <jd...@gm...> - 2008年12月27日 16:43:37
On Sat, Dec 27, 2008 at 10:29 AM, Kaushik Ghose
<Kau...@hm...> wrote:
> Hi Gang,
>
> I was plotting some data collected from an ADC and noticed an odd aliasing
> issue. Please see the images on the following site.
>
> http://assorted-experience.blogspot.com/2008/12/odd-aliasing-issue-with-matplotlib.html
>
> I wonder if there is any way to avoid this kind of aliasing. I vaguely remember
> our old arch-foe (MATLAB) handles this gracefully. I have found matplotlib's
> plotting to be superior to MATLAB's in every way (except for 3D) and it would be
> nice if aliasing could be handled gracefully.
I'm almost certain this is a result of the path simplification logic.
Could you upload some sample data and a self contained script so we
can test?
You can test this by editing site-packages/path.py and replacing::
 self.should_simplify = (len(vertices) >= 128 and
 (codes is None or np.all(codes <= Path.LINETO)))
with::
 self.should_simplify = False
Michael, perhaps we could override path.should_simplify with an rc or
line property?
> Also, thanks for the excellent binary packages for Mac!
Thanks for testing them!
From: Kaushik G. <Kau...@hm...> - 2008年12月27日 16:28:37
Hi Gang,
I was plotting some data collected from an ADC and noticed an odd aliasing 
issue. Please see the images on the following site.
http://assorted-experience.blogspot.com/2008/12/odd-aliasing-issue-with-matplotlib.html
I wonder if there is any way to avoid this kind of aliasing. I vaguely remember 
our old arch-foe (MATLAB) handles this gracefully. I have found matplotlib's 
plotting to be superior to MATLAB's in every way (except for 3D) and it would be 
nice if aliasing could be handled gracefully.
Also, thanks for the excellent binary packages for Mac!
Many thanks
-Kaushik
From: Adam M. <ram...@gm...> - 2008年12月26日 14:37:04
On Fri, Dec 26, 2008 at 13:54, John Hunter <jd...@gm...> wrote:
> Could you please post a complete, free-standing example? Also, you
> might want to test against 98.5.2 which has been released with some
> legend fixes.
Thanks John, updating to 0.98.5.2 fixes the problem.
Cheers
Adam
From: John H. <jd...@gm...> - 2008年12月26日 13:54:41
On Fri, Dec 26, 2008 at 4:14 AM, Adam Mercer <ram...@gm...> wrote:
> Hi
>
> I've noticed that one of my codes is failing with the following
> backtrace since updating to 0.98.5.1:
Could you please post a complete, free-standing example? Also, you
might want to test against 98.5.2 which has been released with some
legend fixes.
JDH
From: Adam M. <ram...@gm...> - 2008年12月26日 10:14:06
Hi
I've noticed that one of my codes is failing with the following
backtrace since updating to 0.98.5.1:
Traceback (most recent call last):
 File "./plot_data.py", line 153, in <module>
 fig.savefig(plot_file)
 File "/opt/local/lib/python2.5/site-packages/matplotlib/figure.py",
line 990, in savefig
 self.canvas.print_figure(*args, **kwargs)
 File "/opt/local/lib/python2.5/site-packages/matplotlib/backend_bases.py",
line 1419, in print_figure
 **kwargs)
 File "/opt/local/lib/python2.5/site-packages/matplotlib/backends/backend_agg.py",
line 323, in print_png
 FigureCanvasAgg.draw(self)
 File "/opt/local/lib/python2.5/site-packages/matplotlib/backends/backend_agg.py",
line 279, in draw
 self.figure.draw(self.renderer)
 File "/opt/local/lib/python2.5/site-packages/matplotlib/figure.py",
line 772, in draw
 for a in self.axes: a.draw(renderer)
 File "/opt/local/lib/python2.5/site-packages/matplotlib/axes.py",
line 1601, in draw
 a.draw(renderer)
 File "/opt/local/lib/python2.5/site-packages/matplotlib/legend.py",
line 347, in draw
 bbox = self._legend_box.get_window_extent(renderer)
 File "/opt/local/lib/python2.5/site-packages/matplotlib/offsetbox.py",
line 198, in get_window_extent
 px, py = self.get_offset(w, h, xd, yd)
 File "/opt/local/lib/python2.5/site-packages/matplotlib/offsetbox.py",
line 157, in get_offset
 return self._offset(width, height, xdescent, ydescent)
 File "/opt/local/lib/python2.5/site-packages/matplotlib/legend.py",
line 299, in _findoffset_best
 ox, oy = self._find_best_position(width, height)
 File "/opt/local/lib/python2.5/site-packages/matplotlib/legend.py",
line 699, in _find_best_position
 consider = [self._get_anchored_bbox(x, bbox, self.parent.bbox) for
x in range(1, len(self.codes))]
TypeError: _get_anchored_bbox() takes exactly 5 arguments (4 given)
make: *** [data.png] Error 1
I can't remember seeing this with 0.98.5. This is clearly related to
the legend as if I remove the code that sets the legend:
x_axes.legend(([x1_plot], [x1_plot]), ("Duration",
 "Amount"), numpoints=1, loc=0, borderpad=2, shadow=True)
then the plot is produced as expected. Is this a regression, or am I
doing something odd with the legend?
Cheers
Adam
From: John H. <jd...@gm...> - 2008年12月24日 16:14:34
On Tue, Dec 23, 2008 at 11:48 PM, Balaji S. Srinivasan
<ba...@st...> wrote:
> I figured out that this was due to an extra comma in setupext.py.
> Edit line 1347 to remove the extra comma, changing this:
>
> module = Extension(
>
> 'matplotlib.backends._backend_gdk',
> ['src/backend_gdk.c', ], #<---- HERE IS THE BAD EXTRA COMMA
> libraries = [],
> include_dirs=numpy_inc_dirs,
> )
>
> to this:
>
> module = Extension(
>
> 'matplotlib.backends._backend_gdk',
> ['src/backend_gdk.c' ],
> libraries = [],
> include_dirs=numpy_inc_dirs,
> )
>
> Then
This doesn't make any sense, because the two lists are identical::
In [127]: x = ['src/backend_gdk.c', ]
In [128]: len(x)
Out[128]: 1
In [129]: x
Out[129]: ['src/backend_gdk.c']
In [130]: y = ['src/backend_gdk.c']
In [131]: len(y)
Out[131]: 1
In [132]: y
Out[132]: ['src/backend_gdk.c']
In [133]: x==y
Out[133]: True
From: Jeff W. <js...@fa...> - 2008年12月24日 14:04:14
Mauro Cavalcanti wrote:
> Dear Anton,
>
> 2008年12月23日 antonv <vas...@ya...>:
> 
>> Also, because I figured out the data I need and already have the scripts in place
>> to extract the CSV files I would really like to keep it that way. Would it be possible to
>> just show me how to get from the csv file to the plot?
>> 
>
> Here is a short recipe:
>
> import numpy as np
>
> f = open("file.csv", "r")
> coords = np.loadtxt(f, delimiter=",", skiprows=1)
> lon = coords[:,0]
> lat = coords[:,1]
> dat = coords[:,2]
>
> where "file.csv" is a regular comma-separated values file in the format:
>
> Lat,Lon,Dat
> -61.05,10.4,20
> -79.43,9.15,50
> -70.66,9.53,10
> -63.11,7.91,40
> ...
>
> Hope this helps!
>
> Best regards,
>
> 
Since the arrays are 2D (for gridded data), a reshape is also needed, i.e.
lon.shape = (nlats,nlons)
lat.shape = (nlats,nlons)
data.shape = (nlats,nlons)
You'll need to know what the grid dimensons (nlats,nlons) are.
-Jeff
From: Mauro C. <mau...@gm...> - 2008年12月24日 10:25:19
Dear Anton,
2008年12月23日 antonv <vas...@ya...>:
> Also, because I figured out the data I need and already have the scripts in place
> to extract the CSV files I would really like to keep it that way. Would it be possible to
> just show me how to get from the csv file to the plot?
Here is a short recipe:
import numpy as np
f = open("file.csv", "r")
coords = np.loadtxt(f, delimiter=",", skiprows=1)
lon = coords[:,0]
lat = coords[:,1]
dat = coords[:,2]
where "file.csv" is a regular comma-separated values file in the format:
Lat,Lon,Dat
-61.05,10.4,20
-79.43,9.15,50
-70.66,9.53,10
-63.11,7.91,40
...
Hope this helps!
Best regards,
-- 
Dr. Mauro J. Cavalcanti
Ecoinformatics Studio
P.O. Box 46521, CEP 20551-970
Rio de Janeiro, RJ, BRASIL
E-mail: mau...@gm...
Web: http://studio.infobio.net
Linux Registered User #473524 * Ubuntu User #22717
"Life is complex. It consists of real and imaginary parts."
From: Balaji S. S. <ba...@st...> - 2008年12月24日 05:48:05
Hi,
I had the following error message when I tried to install
matplotlib-0.98.5.2.tar.gz from source.
The build and install process seemed to proceed without errors, but when I
tried
"import pylab", I got the following traceback:
 File /usr/local/lib/python2.5/site-packages/pylab.py, line 1, in
<module>
 from matplotlib.pylab import *
 File /usr/local/lib/python2.5/site-packages/matplotlib/pylab.py, line
249, in <module>
 from matplotlib.pyplot import *
 File /usr/local/lib/python2.5/site-packages/matplotlib/pyplot.py, line
75, in <module>
 new_figure_manager, draw_if_interactive, show = pylab_setup()
 File /usr/local/lib/python2.5/site-packages/matplotlib/backends/init.py,
line 23, in pylab_setup
 globals(),locals(),[backend_name])
 File
/usr/local/lib/python2.5/site-packages/matplotlib/backends/backend_gtkagg.py,
line 10, in <module>
 from matplotlib.backends.backend_gtk import gtk, FigureManagerGTK,
FigureCanvasGTK, File
/usr/local/lib/python2.5/site-packages/matplotlib/backends/backend_gtk.py,
line 21, in <module>
 from matplotlib.backends.backend_gdk import RendererGDK,
FigureCanvasGDK
 File
/usr/local/lib/python2.5/site-packages/matplotlib/backends/backend_gdk.py,
line 29, in <module>
 from matplotlib.backends._backend_gdk import pixbuf_get_pixels_array
ImportError: No module named _backend_gdk
I figured out that this was due to an extra comma in setupext.py.
Edit line 1347 to remove the extra comma, changing this:
 module = Extension(
 'matplotlib.backends._backend_gdk',
['src/backend_gdk.c', ], #<---- HERE IS THE BAD EXTRA COMMA
libraries = [],
include_dirs=numpy_inc_dirs,
)
 to this:
 module = Extension(
 'matplotlib.backends._backend_gdk',
['src/backend_gdk.c' ],
libraries = [],
include_dirs=numpy_inc_dirs,
)
 Then
python setup.py build
sudo python setup.py install
python -c "import pylab"
works as expected.
From: antonv <vas...@ya...> - 2008年12月23日 20:14:49
Is there a PyNIO binary for windows as on their download page there are only
Linux, Mac or Solaris versions?
Jeff Whitaker wrote:
> 
> vas...@ya... wrote:
>> Hi Jeff,
>>
>> This example is just awesome! I really appreciate the time you put into
>> this but it's way way over my head... There are a couple issues I have
>> especially that I just started using python and matplotlib a couple days
>> ago. First, the direct reading of the grib file is great but I am not
>> able to download Nio. The link they sent me to confirm the registration
>> goes to a page that is not available...
> Anton: I downloaded and installed it this morning and it worked fine. 
> If you're having problems, I'd suggest emailing them - they are quite 
> responsive.
>> Also, because I figured out the data I need and already have the scripts
>> in place to extract the CSV files I would really like to keep it that
>> way. Would it be possible to just show me how to get from the csv file to
>> the plot?
>> 
> It's a matter of reading the CSV files into 2D arrays (lons,lats,data). 
> I don't have time right now to work that out for your data. Anyway, I 
> think you'll be happier in the long run if you bite the bullet now and 
> learn how to use PyNIO to read the data.
> 
> -Jeff
>> Thanks a lot!
>> Anton Vasilescu
>>
>>
>> Jeff Whitaker wrote:
>> 
>>> antonv wrote:
>>> 
>>>> Better yet, here is the file that I am using on my testing but keep in
>>>> mind
>>>> that it's a 33mb file:
>>>> http://downloads.75ive.com/enp.t18z.grib.grib2
>>>> 
>>>> 
>>> Anton: I had already downloaded a file from the ftp site, so here's an 
>>> example script:
>>>
>>> import Nio
>>> from mpl_toolkits.basemap import Basemap
>>> import matplotlib.pyplot as plt
>>> import numpy as np
>>> f = Nio.open_file('akw.t00z.grib.grib2')
>>> print f.variables.keys()
>>> lons = f.variables['lon_0'][:]
>>> # flip latitudes so data goes S-->N
>>> lats = f.variables['lat_0'][::-1]
>>> times = f.variables['forecast_time0'][:]
>>> datavar = f.variables['WWSWHGT_P0_L1_GLL0']
>>> ntime = 10
>>> data = datavar[ntime,::-1]
>>> print f.variables['WWSWHGT_P0_L1_GLL0']
>>> print data.min(), data.max()
>>> m = Basemap(projection='cyl',llcrnrlat=lats[0],llcrnrlon=lons[0],\
>>> urcrnrlat=lats[-1],urcrnrlon=lons[-1],resolution='l')
>>> x, y = m(*np.meshgrid(lons, lats))
>>> levels = np.arange(0,9.1,0.5)
>>> m.contourf(x,y,data,levels)
>>> m.drawcoastlines()
>>> m.fillcontinents()
>>> m.drawparallels(np.arange(40,81,10),labels=[1,0,0,0])
>>> m.drawmeridians(np.arange(150,241,10),labels=[0,0,0,1])
>>> m.drawparallels(np.arange(40,81,10),labels=[1,0,0,0])
>>> m.drawmeridians(np.arange(150,241,10),labels=[0,0,0,1])
>>> plt.title(datavar.long_name+' %s hr fcst'%(times[ntime]),fontsize=12)
>>> plt.colorbar(orientation='horizontal',shrink=0.9,format="%g")
>>> plt.show()
>>>
>>> The resulting plot is attached.
>>>
>>> Note you will need the Basemap toolkit (available from the matplotlib 
>>> download site). If you don't want to plot the coastlines, you can just 
>>> use plt.contourf. You'll also need PyNIO 
>>> (http://www.pyngl.ucar.edu/Nio.shtml) to read the GRIB file.
>>>
>>> The png produced by this script is attached.
>>>
>>> Let me know if you have any questions.
>>>
>>> -Jeff
>>> 
>>>>
>>>> antonv wrote:
>>>> 
>>>> 
>>>>> Here is the link to the folder that has the grib files. They are
>>>>> updated
>>>>> every 3 hours:
>>>>> ftp://ftpprd.ncep.noaa.gov/pub/data/nccf/com/wave/prod/
>>>>>
>>>>> Any of the files there would have the same info only at different
>>>>> times
>>>>> of
>>>>> day.
>>>>>
>>>>>
>>>>> 
>>>>> 
>>>> 
>>>> 
>>> 
>>> ------------------------------------------------------------------------------
>>>
>>> _______________________________________________
>>> Matplotlib-users mailing list
>>> Mat...@li...
>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>>
>>>
>>> 
>> Quoted from: 
>> http://www.nabble.com/Plotting-NOAA-data...-tp21139727p21149409.html
>>
>> 
> 
> 
> ------------------------------------------------------------------------------
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
> 
-- 
View this message in context: http://www.nabble.com/Plotting-NOAA-data...-tp21139727p21150608.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: Jeff W. <js...@fa...> - 2008年12月23日 19:41:28
vas...@ya... wrote:
> Hi Jeff,
>
> This example is just awesome! I really appreciate the time you put into this but it's way way over my head... There are a couple issues I have especially that I just started using python and matplotlib a couple days ago. First, the direct reading of the grib file is great but I am not able to download Nio. The link they sent me to confirm the registration goes to a page that is not available...
Anton: I downloaded and installed it this morning and it worked fine. 
If you're having problems, I'd suggest emailing them - they are quite 
responsive.
> Also, because I figured out the data I need and already have the scripts in place to extract the CSV files I would really like to keep it that way. Would it be possible to just show me how to get from the csv file to the plot?
> 
It's a matter of reading the CSV files into 2D arrays (lons,lats,data). 
I don't have time right now to work that out for your data. Anyway, I 
think you'll be happier in the long run if you bite the bullet now and 
learn how to use PyNIO to read the data.
-Jeff
> Thanks a lot!
> Anton Vasilescu
>
>
> Jeff Whitaker wrote:
> 
>> antonv wrote:
>> 
>>> Better yet, here is the file that I am using on my testing but keep in
>>> mind
>>> that it's a 33mb file:
>>> http://downloads.75ive.com/enp.t18z.grib.grib2
>>> 
>>> 
>> Anton: I had already downloaded a file from the ftp site, so here's an 
>> example script:
>>
>> import Nio
>> from mpl_toolkits.basemap import Basemap
>> import matplotlib.pyplot as plt
>> import numpy as np
>> f = Nio.open_file('akw.t00z.grib.grib2')
>> print f.variables.keys()
>> lons = f.variables['lon_0'][:]
>> # flip latitudes so data goes S-->N
>> lats = f.variables['lat_0'][::-1]
>> times = f.variables['forecast_time0'][:]
>> datavar = f.variables['WWSWHGT_P0_L1_GLL0']
>> ntime = 10
>> data = datavar[ntime,::-1]
>> print f.variables['WWSWHGT_P0_L1_GLL0']
>> print data.min(), data.max()
>> m = Basemap(projection='cyl',llcrnrlat=lats[0],llcrnrlon=lons[0],\
>> urcrnrlat=lats[-1],urcrnrlon=lons[-1],resolution='l')
>> x, y = m(*np.meshgrid(lons, lats))
>> levels = np.arange(0,9.1,0.5)
>> m.contourf(x,y,data,levels)
>> m.drawcoastlines()
>> m.fillcontinents()
>> m.drawparallels(np.arange(40,81,10),labels=[1,0,0,0])
>> m.drawmeridians(np.arange(150,241,10),labels=[0,0,0,1])
>> m.drawparallels(np.arange(40,81,10),labels=[1,0,0,0])
>> m.drawmeridians(np.arange(150,241,10),labels=[0,0,0,1])
>> plt.title(datavar.long_name+' %s hr fcst'%(times[ntime]),fontsize=12)
>> plt.colorbar(orientation='horizontal',shrink=0.9,format="%g")
>> plt.show()
>>
>> The resulting plot is attached.
>>
>> Note you will need the Basemap toolkit (available from the matplotlib 
>> download site). If you don't want to plot the coastlines, you can just 
>> use plt.contourf. You'll also need PyNIO 
>> (http://www.pyngl.ucar.edu/Nio.shtml) to read the GRIB file.
>>
>> The png produced by this script is attached.
>>
>> Let me know if you have any questions.
>>
>> -Jeff
>> 
>>>
>>> antonv wrote:
>>> 
>>> 
>>>> Here is the link to the folder that has the grib files. They are updated
>>>> every 3 hours:
>>>> ftp://ftpprd.ncep.noaa.gov/pub/data/nccf/com/wave/prod/
>>>>
>>>> Any of the files there would have the same info only at different times
>>>> of
>>>> day.
>>>>
>>>>
>>>> 
>>>> 
>>> 
>>> 
>> 
>> ------------------------------------------------------------------------------
>>
>> _______________________________________________
>> Matplotlib-users mailing list
>> Mat...@li...
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
>>
>> 
> Quoted from: 
> http://www.nabble.com/Plotting-NOAA-data...-tp21139727p21149409.html
>
> 
From: Jeff W. <js...@fa...> - 2008年12月23日 18:46:55
Attachments: testgrib.png
antonv wrote:
> Better yet, here is the file that I am using on my testing but keep in mind
> that it's a 33mb file:
> http://downloads.75ive.com/enp.t18z.grib.grib2
> 
Anton: I had already downloaded a file from the ftp site, so here's an 
example script:
import Nio
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
import numpy as np
f = Nio.open_file('akw.t00z.grib.grib2')
print f.variables.keys()
lons = f.variables['lon_0'][:]
# flip latitudes so data goes S-->N
lats = f.variables['lat_0'][::-1]
times = f.variables['forecast_time0'][:]
datavar = f.variables['WWSWHGT_P0_L1_GLL0']
ntime = 10
data = datavar[ntime,::-1]
print f.variables['WWSWHGT_P0_L1_GLL0']
print data.min(), data.max()
m = Basemap(projection='cyl',llcrnrlat=lats[0],llcrnrlon=lons[0],\
 urcrnrlat=lats[-1],urcrnrlon=lons[-1],resolution='l')
x, y = m(*np.meshgrid(lons, lats))
levels = np.arange(0,9.1,0.5)
m.contourf(x,y,data,levels)
m.drawcoastlines()
m.fillcontinents()
m.drawparallels(np.arange(40,81,10),labels=[1,0,0,0])
m.drawmeridians(np.arange(150,241,10),labels=[0,0,0,1])
m.drawparallels(np.arange(40,81,10),labels=[1,0,0,0])
m.drawmeridians(np.arange(150,241,10),labels=[0,0,0,1])
plt.title(datavar.long_name+' %s hr fcst'%(times[ntime]),fontsize=12)
plt.colorbar(orientation='horizontal',shrink=0.9,format="%g")
plt.show()
The resulting plot is attached.
Note you will need the Basemap toolkit (available from the matplotlib 
download site). If you don't want to plot the coastlines, you can just 
use plt.contourf. You'll also need PyNIO 
(http://www.pyngl.ucar.edu/Nio.shtml) to read the GRIB file.
The png produced by this script is attached.
Let me know if you have any questions.
-Jeff
>
>
>
> antonv wrote:
> 
>> Here is the link to the folder that has the grib files. They are updated
>> every 3 hours:
>> ftp://ftpprd.ncep.noaa.gov/pub/data/nccf/com/wave/prod/
>>
>> Any of the files there would have the same info only at different times of
>> day.
>>
>>
>> 
>
> 
From: antonv <vas...@ya...> - 2008年12月23日 18:12:39
Better yet, here is the file that I am using on my testing but keep in mind
that it's a 33mb file:
http://downloads.75ive.com/enp.t18z.grib.grib2
antonv wrote:
> 
> Here is the link to the folder that has the grib files. They are updated
> every 3 hours:
> ftp://ftpprd.ncep.noaa.gov/pub/data/nccf/com/wave/prod/
> 
> Any of the files there would have the same info only at different times of
> day.
> 
> 
-- 
View this message in context: http://www.nabble.com/Plotting-NOAA-data...-tp21139727p21148866.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: antonv <vas...@ya...> - 2008年12月23日 18:02:16
Here is the link to the folder that has the grib files. They are updated
every 3 hours:
ftp://ftpprd.ncep.noaa.gov/pub/data/nccf/com/wave/prod/
Any of the files there would have the same info only at different times of
day.
-- 
View this message in context: http://www.nabble.com/Plotting-NOAA-data...-tp21139727p21148738.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: Jeff W. <js...@fa...> - 2008年12月23日 17:56:56
antonv wrote:
> Hi Jeff, here is a link to the csv file:
> http://downloads.75ive.com/testdata.csv
>
> Thanks again for all your help guys! Really appreciated!
>
> 
I meant the original GRIB file ...
-Jeff
> Ryan May-3 wrote:
> 
>> KURT PETERS wrote:
>> 
>>> Sorry, I meant the griddata module as part of mlab.
>>> Kurt
>>>
>>> 
>> It was first released in 0.98.3.
>>
>> Ryan
>>
>> -- 
>> Ryan May
>> Graduate Research Assistant
>> School of Meteorology
>> University of Oklahoma
>>
>> ------------------------------------------------------------------------------
>> _______________________________________________
>> Matplotlib-users mailing list
>> Mat...@li...
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
>>
>> 
>
> 
From: antonv <vas...@ya...> - 2008年12月23日 17:30:56
Hi Jeff, here is a link to the csv file:
http://downloads.75ive.com/testdata.csv
Thanks again for all your help guys! Really appreciated!
Ryan May-3 wrote:
> 
> KURT PETERS wrote:
>> Sorry, I meant the griddata module as part of mlab.
>> Kurt
>> 
> 
> It was first released in 0.98.3.
> 
> Ryan
> 
> -- 
> Ryan May
> Graduate Research Assistant
> School of Meteorology
> University of Oklahoma
> 
> ------------------------------------------------------------------------------
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
> 
-- 
View this message in context: http://www.nabble.com/Plotting-NOAA-data...-tp21139727p21148270.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: Ryan M. <rm...@gm...> - 2008年12月23日 17:20:46
KURT PETERS wrote:
> Sorry, I meant the griddata module as part of mlab.
> Kurt
> 
It was first released in 0.98.3.
Ryan
-- 
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma
From: Jeff W. <js...@fa...> - 2008年12月23日 16:58:47
antonv wrote:
> Scott, the Scatter function works great but i am really looking to use the
> contourf one.
>
> Eric, you're right, the way I had it initially it was missing the z value. I
> looked at the griddata example and here is the code I came up with:
> 
Since you read your data from a GRIB file, it must be on a regular 
grid. Therefore, you don't need to use griddata to grid your data.
The best way to go would be to use PyNIO to read the grib data into a 2D 
array, and then plot it directly with contourf (perhaps using the 
Basemap toolkit if you want to display a map underneath). 
If you point me to your GRIB file I can show you what I mean.
-Jeff
> from numpy.random import uniform, seed
> from matplotlib.mlab import griddata
> import matplotlib.pyplot as plt
> import numpy as np
>
> r =
> mlab.csv2rec('D:/SocalScubaInfo/Data/Outputs/CSV_files/DIRPW_12191800.csv')
>
> x = r.longitude
> y = r.latitude
> z = r.dirpw_200812191800
> xi = r.x 
> yi = r.y
>
> # grid the data.
> zi = griddata(x,y,z,xi,yi)
>
> CS = plt.contourf(xi,yi,zi,15,cmap=plt.cm.jet)
> plt.colorbar() # draw colorbar
>
> plt.show()
>
>
> Which still errors out: 'output grid defined by xi,yi must be monotone
> increasing'
> The xi and yi are from the first 2 columns of the csv file and I thought
> they were monotonically increasing. What am I missing?
>
> antonv wrote:
> 
>> Hi all,
>>
>> I am pretty new to matplotlib and I have a big issue... I am trying to
>> plot data from a grib file from noaa and I am not sure what's the best way
>> to go about it. Until now, I am extracting the data i need in CSV files
>> but I am not able to plot it. Here is a sample of the code that I am
>> using:
>>
>> import matplotlib.pyplot as plt
>> import matplotlib.mlab as mlab
>>
>> r =
>> mlab.csv2rec('D:/SocalScubaInfo/Data/Outputs/CSV_files/DIRPW_12191800.csv')
>> plt.contour(r.longitude, r.latitude)
>> plt.show()
>>
>> Which errors out and requires a 2d array.
>>
>> By the way, here is a data file: http://downloads.75ive.com/testdata.csv
>> http://downloads.75ive.com/testdata.csv 
>>
>> Any help is appreciated!
>>
>> 
>
> 
From: KURT P. <pet...@ms...> - 2008年12月23日 16:30:44
Sorry, I meant the griddata module as part of mlab.KurtFrom: pet...@ms...To: mat...@li...Subject: RE: Plotting NOAA data...Date: 2008年12月23日 09:28:49 -0700
I don't seem to have a mlab module as part of matplotlib. Is that something new?Kurt
From: KURT P. <pet...@ms...> - 2008年12月23日 16:30:11
I don't seem to have a mlab module as part of matplotlib. Is that something new?Kurt
From: antonv <vas...@ya...> - 2008年12月23日 16:16:01
Scott, the Scatter function works great but i am really looking to use the
contourf one.
Eric, you're right, the way I had it initially it was missing the z value. I
looked at the griddata example and here is the code I came up with:
from numpy.random import uniform, seed
from matplotlib.mlab import griddata
import matplotlib.pyplot as plt
import numpy as np
r =
mlab.csv2rec('D:/SocalScubaInfo/Data/Outputs/CSV_files/DIRPW_12191800.csv')
x = r.longitude
y = r.latitude
z = r.dirpw_200812191800
xi = r.x 
yi = r.y
# grid the data.
zi = griddata(x,y,z,xi,yi)
CS = plt.contourf(xi,yi,zi,15,cmap=plt.cm.jet)
plt.colorbar() # draw colorbar
plt.show()
Which still errors out: 'output grid defined by xi,yi must be monotone
increasing'
The xi and yi are from the first 2 columns of the csv file and I thought
they were monotonically increasing. What am I missing?
antonv wrote:
> 
> Hi all,
> 
> I am pretty new to matplotlib and I have a big issue... I am trying to
> plot data from a grib file from noaa and I am not sure what's the best way
> to go about it. Until now, I am extracting the data i need in CSV files
> but I am not able to plot it. Here is a sample of the code that I am
> using:
> 
> import matplotlib.pyplot as plt
> import matplotlib.mlab as mlab
> 
> r =
> mlab.csv2rec('D:/SocalScubaInfo/Data/Outputs/CSV_files/DIRPW_12191800.csv')
> plt.contour(r.longitude, r.latitude)
> plt.show()
> 
> Which errors out and requires a 2d array.
> 
> By the way, here is a data file: http://downloads.75ive.com/testdata.csv
> http://downloads.75ive.com/testdata.csv 
> 
> Any help is appreciated!
> 
-- 
View this message in context: http://www.nabble.com/Plotting-NOAA-data...-tp21139727p21147081.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: Scott S. <sco...@gm...> - 2008年12月23日 10:25:58
>2008年12月23日 Eric Firing <ef...@ha...>:
> antonv wrote:
>> Hi all,
>>
>> I am trying to plot data from a grib file from noaa ...
>> Here is a sample of the code that I am using:
>>
>> import matplotlib.pyplot as plt
>> import matplotlib.mlab as mlab
>>
>> r =
>> mlab.csv2rec('D:/SocalScubaInfo/Data/Outputs/CSV_files/DIRPW_12191800.csv')
>> plt.contour(r.longitude, r.latitude)
>> plt.show()
>>
>> Which errors out and requires a 2d array.
>>
>> By the way, here is a data file: http://downloads.75ive.com/testdata.csv
>> http://downloads.75ive.com/testdata.csv
>>
>> Any help is appreciated!
>
>
> I assume you meant to include your dependent variable in the call to
> contour, not just your longitude and latitude. In any case, you need to
> grid your data onto a 2D array. In the mpl examples, see griddata_demo.py.
If you just want a quick overview, you could also try
>>> plt.scatter(r.longitude, r.latitude, c=r.dirpw_200812191800, s=5, edgecolors='none')
>>> plt.colorbar()
>>> plt.show()
Cheers,
Scott
From: Eric F. <ef...@ha...> - 2008年12月23日 07:18:34
antonv wrote:
> Hi all,
> 
> I am pretty new to matplotlib and I have a big issue... I am trying to plot
> data from a grib file from noaa and I am not sure what's the best way to go
> about it. Until now, I am extracting the data i need in CSV files but I am
> not able to plot it. Here is a sample of the code that I am using:
> 
> import matplotlib.pyplot as plt
> import matplotlib.mlab as mlab
> 
> r =
> mlab.csv2rec('D:/SocalScubaInfo/Data/Outputs/CSV_files/DIRPW_12191800.csv')
> plt.contour(r.longitude, r.latitude)
> plt.show()
> 
> Which errors out and requires a 2d array.
> 
> By the way, here is a data file: http://downloads.75ive.com/testdata.csv
> http://downloads.75ive.com/testdata.csv 
> 
> Any help is appreciated!
I assume you meant to include your dependent variable in the call to 
contour, not just your longitude and latitude. In any case, you need to 
grid your data onto a 2D array. In the mpl examples, see griddata_demo.py.
Eric
From: antonv <vas...@ya...> - 2008年12月23日 06:51:58
Hi all,
I am pretty new to matplotlib and I have a big issue... I am trying to plot
data from a grib file from noaa and I am not sure what's the best way to go
about it. Until now, I am extracting the data i need in CSV files but I am
not able to plot it. Here is a sample of the code that I am using:
import matplotlib.pyplot as plt
import matplotlib.mlab as mlab
r =
mlab.csv2rec('D:/SocalScubaInfo/Data/Outputs/CSV_files/DIRPW_12191800.csv')
plt.contour(r.longitude, r.latitude)
plt.show()
Which errors out and requires a 2d array.
By the way, here is a data file: http://downloads.75ive.com/testdata.csv
http://downloads.75ive.com/testdata.csv 
Any help is appreciated!
-- 
View this message in context: http://www.nabble.com/Plotting-NOAA-data...-tp21139727p21139727.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: Jae-Joon L. <lee...@gm...> - 2008年12月22日 17:50:19
On Sun, Dec 21, 2008 at 1:30 PM, Georg Brandl <g.b...@gm...> wrote:
> Hi,
>
> I'm currently using Qwt to display a plot in a GUI application, but I'd like
> to replace it with matplotlib and a shell window, so that the user can not
> only view the plot but also modify it in-place using pyplot commands.
>
> One thing I'd like to do is to adjust the spacing surrounding the plot to be
> constant, regardless of the window size. Since the plot window is resized
> often, it is impossible to use very small subplot params and a waste of
> viewing space to use larger ones when the window is maximized.
>
> Is there a way to make the figure use absolute params like "20 pixels/points"?
>
Axes in matplotlib uses normalized figure coordinates. Therefore, you
have to convert your dimension (say 20 points) into normalized figure
coordinates, and you need to do it whenever your the figure size
changes.
There are ways to do this, but no easy way like
subplots_adjust(left="20 points").
One way is to use axes_divider.py that I recently added In the example
directory (in the svn trunk).
import matplotlib.pyplot as plt
from axes_divider import LocatableAxes, Divider, Size
fig1 = plt.figure(1)
pad=0.8 # inch
v=[Size.Fixed(pad), Size.Scalable(1.),Size.Fixed(pad)]
h=[Size.Fixed(pad), Size.Scalable(1.),Size.Fixed(pad)]
divider = Divider(fig1, [0, 0, 1, 1],
 horizontal=v, vertical=h)
locator = divider.new_locator(nx=1, ny=1)
# axes
ax = LocatableAxes(fig1, divider.get_position())
ax.set_axes_locator(locator)
fig1.add_axes(ax)
plt.draw()
> Second, less important question: is there a way to give default font properties
> (like weight="bold") for axis labels?
>
Unfortunately not, although font size and font color can be set using rcParams.
-JJ
> Third, I normally get my data one point at a time. Is there a more efficient
> way to insert single data points in existing plots than doing
> set_xdata/set_ydata?
>
> Thanks,
> Georg
>
> --
> Thus spake the Lord: Thou shalt indent with four spaces. No more, no less.
> Four shall be the number of spaces thou shalt indent, and the number of thy
> indenting shall be four. Eight shalt thou not indent, nor either indent thou
> two, excepting that thou then proceed to four. Tabs are right out.
>
>
> ------------------------------------------------------------------------------
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
5 messages has been excluded from this view by a project administrator.

Showing results of 432

<< < 1 2 3 4 5 .. 18 > >> (Page 3 of 18)
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 によって変換されたページ (->オリジナル) /