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 15 results of 15

From: Ken M. <mc...@ii...> - 2008年12月09日 20:36:07
Massimo,
I'm sorry I didn't reply to your email. It fell through the cracks, 
so to speak.
WxMpl development has been stalled for quite some time now because I 
developed bilateral carpal tunnel syndrome this past spring. It was 
not my intention to leave it abandoned and incompatible with 
matplotlib, but I've been finding everything to be a bit of an uphill 
battle these days.
My current plan is to spend some time later this month bringing WxMpl 
up to date with the API changes. I'd be very pleased to see it hosted 
as a matplotlib toolkit, so I'll move it over once it's working 
properly. If someone wants to move the source over and start hacking 
on it in the interim, please be my guest.
Ken
On Nov 21, 2008, at 4:52 AM, massimo sandal wrote:
> Hi,
>
> I am a wxMPL user. I use it as a component to blend MPL into a wx 
> GUI for a data analysis application I develop ( http://code.google.com/p/hooke 
> ).
>
> I was extremly satisfied by that package, but I've noticed it 
> doesn't play well with latest mpl and needs to be patched. Another 
> wonderful guy on this list (Paulo Meira) managed to patch it get it 
> working but I am receiving reports it could be still buggy and it is 
> a completely unofficial patch.
>
> I tried to wrote to Ken McIvor (wxmpl author) about this but 
> received no answer.
> So, I'd like to know:
> - Is anyone able to contact Ken McIvor?
> - Does anyone know about the wxmpl status?
> - If wxmpl has been abandoned by its author, is there anyone 
> interested (beyond myself) in continuing its development?
>
> Thanks a lot,
> Massimo
>
> -- 
> Massimo Sandal , Ph.D.
> University of Bologna
> Department of Biochemistry "G.Moruzzi"
>
> snail mail:
> Via Irnerio 48, 40126 Bologna, Italy
>
> email:
> mas...@un...
>
> web:
> http://www.biocfarm.unibo.it/samori/people/sandal.html
>
> tel: +39-051-2094388
> fax: +39-051-2094387
> < 
> massimo_sandal 
> .vcf 
> > 
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's 
> challenge
> Build the coolest Linux based applications with Moblin SDK & win 
> great prizes
> Grand prize is a trip for two to an Open Source event anywhere in 
> the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/_______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: Mauro C. <mau...@gm...> - 2008年12月09日 20:10:38
Dear John,
Thanks, it works well!
Best regards,
2008年12月9日 John Hunter <jd...@gm...>:
> Yep, we have a color converter for that -- it recognizes any mpl color
> string and returns rgba:
>
> In [72]: from matplotlib.colors import colorConverter
>
> In [73]: colorConverter.to_rgba('b')
> Out[73]: (0.0, 0.0, 1.0, 1.0)
>
> In [74]: colorConverter.to_rgba('blue')
> Out[74]: (0.0, 0.0, 1.0, 1.0)
>
-- 
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: John H. <jd...@gm...> - 2008年12月09日 19:24:23
On Tue, Dec 9, 2008 at 1:01 PM, Mauro Cavalcanti <mau...@gm...> wrote:
> Dear ALL,
>
> MPL accepts several formats for passing color information for the
> plotting methods (plot, xlabel, ylabel, etc.) and these are well
> documented. The set_color() and other methods in
> matplotlib.Lines.Line2D accept all these formats, but I could not
> figure out how to retrieve the current color of a plot using the
> get_color() method in a format other than the 'b', 'r', 'g', etc.
> predefined color symbols! I would instead like to be able to retrieve
> the current color in RGB hex or HTML format. Is it possible?
Yep, we have a color converter for that -- it recognizes any mpl color
string and returns rgba:
In [72]: from matplotlib.colors import colorConverter
In [73]: colorConverter.to_rgba('b')
Out[73]: (0.0, 0.0, 1.0, 1.0)
In [74]: colorConverter.to_rgba('blue')
Out[74]: (0.0, 0.0, 1.0, 1.0)
From: Mauro C. <mau...@gm...> - 2008年12月09日 19:02:01
Dear ALL,
MPL accepts several formats for passing color information for the
plotting methods (plot, xlabel, ylabel, etc.) and these are well
documented. The set_color() and other methods in
matplotlib.Lines.Line2D accept all these formats, but I could not
figure out how to retrieve the current color of a plot using the
get_color() method in a format other than the 'b', 'r', 'g', etc.
predefined color symbols! I would instead like to be able to retrieve
the current color in RGB hex or HTML format. Is it possible?
Thanks in advance!
With 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: Mauro C. <mau...@gm...> - 2008年12月09日 17:12:25
Dear Scott & Jeff,
Sorry for the delay in replying, I was off office for a while.
2008年12月9日 Scott Sinclair <sco...@gm...>:
> As Jeff noted earlier, the number of elements in an array can't be
> increased simply by reshaping it, so the error message isn't too
> mysterious, if carefully considered.
Sure, I got lost because I tried to follow the solution previously
presented in the posting I referred to, since the example data I
provided are identical in format to that used in that solution (a
3-column space delimited file, with the first two representing the
longitude and latitude, and the 3rd representing the variable of
interest).
> 1. You have a small number of scattered data values in 'grid.dat' with
> their locations specified by lat/lon co-ordinates.
> 2. You want to create a regular square/rectangular grid that spans
> your region of interest and assign the values in 'grid.dat' to the
> grid box in which they fall, with all other regions of the grid being
> masked.
> 3. You then want to plot the masked rectangular grid onto a Basemap instance.
You did understood it very correctly, and of course offered a much
better description than I could provide myself using my pidgin English
:-). Indeed, there is just one detail to add to the above problem
description, and this is the fact that the "region of interest" may
span the entire world (land or sea, depending on the biological
organism under study).
> The attached script shows one way to do this (using the imshow
> method), I've left the task assigning the data values to the correct
> grid box for you..
Thank you very much, I feel somewhat ashamed! Anyway, the final
product of this project will be made freely available under GPL, so it
will belong to everyone (and due credit will be given to all of you
meteorologists, physicists, mathematicians, etc. that have been so
helpful!)
Returning to the techical aspects of the problem, it is indeed the
assignment of data values to the correct grid box that lays in the
core of the second part of my question -- it may indeed be not so
difficult as the previous requirement, that is to build the data file
(with the data values of interest) *before* the grid analysis, from
simple lat-long files for each species under study (usually up to 20,
but may be more). But I will develop this further.
One more detail: is it possible to plot the value of the variable of
interest, corresponding to each square of the grid, inside the
respective square?
With warmest 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: Scott S. <sco...@gm...> - 2008年12月09日 16:33:39
Attachments: temp.py
> Mauro Cavalcanti wrote:
> I tried to do:
>
> coords = numpy.loadtxt('grid.dat')
> lon = coords[:,0]
> lat = coords[:,1]
> dat = coords[:,2]
> X, Y = numpy.meshgrid(lon, lat)
> nlons = X.shape[1]
> nlats = X.shape[0]
> Z = dat.reshape(nlats,nlons)
>
> (so that I could proceed to plotting with the X,Y,Z arrays), but got
> another error:
>
> "ValueError: total size of new array must be unchanged"
>
> and with this I get lost.... :(
Hi Mauro,
As Jeff noted earlier, the number of elements in an array can't be
increased simply by reshaping it, so the error message isn't too
mysterious, if carefully considered.
This might be a good time to step back from the code for a moment and
consider the problem that needs to be solved.
As I understand it:
1. You have a small number of scattered data values in 'grid.dat' with
their locations specified by lat/lon co-ordinates.
2. You want to create a regular square/rectangular grid that spans
your region of interest and assign the values in 'grid.dat' to the
grid box in which they fall, with all other regions of the grid being
masked.
3. You then want to plot the masked rectangular grid onto a Basemap instance.
The attached script shows one way to do this (using the imshow
method), I've left the task assigning the data values to the correct
grid box for you..
Cheers,
Scott
From: Fago, M. - A. <Mat...@it...> - 2008年12月09日 16:12:40
> From: Ryan May
> The scaling changes are in, as well as the warning and the corresponding
> lines in
> api_changes and CHANGELOG. I also added the converted matlab demo I
> used to
> figure this stuff out. Now would probably be the time to see if I did
> something
> wrong (especially the warning).
The magnitudes do seem better, and the error message works in a reasonable
way (no warning if explicitly set the new arg).
The plot does still look somewhat different from Matlab (e.g., the peak at 150 Hz is much larger in matplotlib), even with window=window_none. Fernando might have a point about unit tests: perhaps we could somehow get a few numerical values out of Matlab to compare to in a test?
Regardless, much better. Thank you!
 - Matt
This e-mail and any files transmitted with it may be proprietary and are intended solely for the use of the individual or entity to whom they are addressed. If you have received this e-mail in error please notify the sender.
Please note that any views or opinions presented in this e-mail are solely those of the author and do not necessarily represent those of ITT Corporation. The recipient should check this e-mail and any attachments for the presence of viruses. ITT accepts no liability for any damage caused by any virus transmitted by this e-mail.
From: Jeff W. <js...@fa...> - 2008年12月09日 15:08:07
Mauro Cavalcanti wrote:
> Dear Jeff,
>
> 2008年12月9日 Jeff Whitaker <js...@fa...>:
> 
>> Mauro: The shape of x, y, and dat must all be (nlats, nlons).
>> 
>
> I tried to do:
>
> coords = numpy.loadtxt('grid.dat')
> lon = coords[:,0]
> lat = coords[:,1]
> dat = coords[:,2]
> X, Y = numpy.meshgrid(lon, lat)
> nlons = X.shape[1]
> nlats = X.shape[0]
> Z = dat.reshape(nlats,nlons)
>
> (so that I could proceed to plotting with the X,Y,Z arrays), but got
> another error:
>
> "ValueError: total size of new array must be unchanged"
>
> and with this I get lost.... :(
>
> I tried to follow the guidelines you provided for Mr. Tim Michelsen on
> a previous post
> (http://www.nabble.com/plotting-a-contour-map-from-CSV-file-td18440459.html)
> but it didn't help (however, that provided me with a solution to
> another problem!).
>
> Best regards,
>
> 
Mauro: This will only work is dat is length(nlons*nlats). Is it?
-Jeff
-- 
Jeffrey S. Whitaker Phone : (303)497-6313
NOAA/OAR/CDC R/PSD1 FAX : (303)497-6449
325 Broadway Boulder, CO, USA 80305-3328
From: Jeff W. <js...@fa...> - 2008年12月09日 13:17:56
Mauro Cavalcanti wrote:
> Dear Jeff,
>
> 2008年12月9日 Jeff Whitaker <js...@fa...>:
> 
>> Assuming that this is a regular grid (so that using meshgrid makes sense)
>> you can
>> 
>
> 
>> using pcolor:
>> m.pcolormesh(x,y,dat)
>> 
>
> Unfortunately, this didn't work. I got the error message (using the
> example data from my previous post):
>
> "File "/usr/lib/python2.5/site-packages/matplotlib/axes.py", line
> 6091, in pcolormesh
> C = ma.ravel(C[0:Ny-1, 0:Nx-1]) # data point in each cell is value at
> IndexError: too many indices"
>
> 
>> using contourf:
>> m.contourf(x,y,dat,clevs)
>> 
>
> Not tried because contour maps are not exactly what I need.
>
> 
>> using imshow:
>> m.imshow(dat)
>> 
>
> Another error message:
>
> " File "/usr/lib/python2.5/site-packages/matplotlib/image.py", line
> 292, in set_data
> raise TypeError("Invalid dimensions for image data")
> TypeError: Invalid dimensions for image data"
>
> (Have I to meshgrid the data first?)
> 
Mauro: The shape of x, y, and dat must all be (nlats, nlons).
> 
>> There are examples of all three included with basemap.
>> 
>
> Indeed, I could not find an example of pcolormesh(). But the
> ccsm_popgrid.py example offers a potential solution for another
> problem (but this is the second part of my question).
> 
test.py includes pcolormesh examples (the call signature for pcolor is 
the same though).
-Jeff
> Best wishes,
>
> 
-- 
Jeffrey S. Whitaker Phone : (303)497-6313
NOAA/OAR/CDC R/PSD1 FAX : (303)497-6449
325 Broadway Boulder, CO, USA 80305-3328
From: Mauro C. <mau...@gm...> - 2008年12月09日 13:05:00
Dear Jeff,
2008年12月9日 Jeff Whitaker <js...@fa...>:
> Assuming that this is a regular grid (so that using meshgrid makes sense)
> you can
> using pcolor:
> m.pcolormesh(x,y,dat)
Unfortunately, this didn't work. I got the error message (using the
example data from my previous post):
"File "/usr/lib/python2.5/site-packages/matplotlib/axes.py", line
6091, in pcolormesh
 C = ma.ravel(C[0:Ny-1, 0:Nx-1]) # data point in each cell is value at
IndexError: too many indices"
> using contourf:
> m.contourf(x,y,dat,clevs)
Not tried because contour maps are not exactly what I need.
> using imshow:
> m.imshow(dat)
Another error message:
" File "/usr/lib/python2.5/site-packages/matplotlib/image.py", line
292, in set_data
 raise TypeError("Invalid dimensions for image data")
TypeError: Invalid dimensions for image data"
(Have I to meshgrid the data first?)
> There are examples of all three included with basemap.
Indeed, I could not find an example of pcolormesh(). But the
ccsm_popgrid.py example offers a potential solution for another
problem (but this is the second part of my question).
Best wishes,
-- 
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: Mauro C. <mau...@gm...> - 2008年12月09日 12:55:06
Dear Jeff,
2008年12月9日 Jeff Whitaker <js...@fa...>:
> Mauro: If your points are defined in terms of longitude and latitude, you
> have to convert to map projection coordinates using the __call__ method of
> the Basemap instance, i.e.
>
> x, y = m(lon, lat) # lon,lat can be arrays, lists or scalars. m is a
> Basemap instance.
>
> You then pass x,y to the plot command (be it 'plot', 'scatter', 'contour' or
> whatever).
>
OK, but since this step is not necessary with the usual
Equirectangular projection, I got confused. Maybe this could also be
included in the documentation?
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: Jeff W. <js...@fa...> - 2008年12月09日 12:42:13
Mauro Cavalcanti wrote:
> Dear Jeff & ALL,
>
> This is just a simple question on plotting points on Basemap (maybe it
> will have to be pursued further). I presume points could be plotted
> onto maps, no matter what projection is used -- so, I have been
> plotting quite well on maps using an Equirectangular projetion and one
> of your "classical" examples shows the plot of points on maps using an
> ortographic projection. However, my points are not displayed when I, 
> change the map projection, say, from Equirectangular to South Polar
> Stereographic, even if most of the points are well within range in the
> new projection. Any hints?
>
> Best regards,
>
> 
Mauro: If your points are defined in terms of longitude and latitude, 
you have to convert to map projection coordinates using the __call__ 
method of the Basemap instance, i.e.
x, y = m(lon, lat) # lon,lat can be arrays, lists or scalars. m is a 
Basemap instance.
You then pass x,y to the plot command (be it 'plot', 'scatter', 
'contour' or whatever).
-Jeff
-- 
Jeffrey S. Whitaker Phone : (303)497-6313
NOAA/OAR/CDC R/PSD1 FAX : (303)497-6449
325 Broadway Boulder, CO, USA 80305-3328
From: Mauro C. <mau...@gm...> - 2008年12月09日 12:37:37
Dear Jeff & ALL,
This is just a simple question on plotting points on Basemap (maybe it
will have to be pursued further). I presume points could be plotted
onto maps, no matter what projection is used -- so, I have been
plotting quite well on maps using an Equirectangular projetion and one
of your "classical" examples shows the plot of points on maps using an
ortographic projection. However, my points are not displayed when I
change the map projection, say, from Equirectangular to South Polar
Stereographic, even if most of the points are well within range in the
new projection. Any hints?
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: Jeff W. <js...@fa...> - 2008年12月09日 12:26:40
Mauro Cavalcanti wrote:
> Dear ALL,
>
> Good morning! Here am I again with the first (and perhaps simpler)
> part of a potentially long question on plotting gridded data using MPL
> (*and* Basemap).
>
> Most examples I have found of plotting gridded data (using either
> MATLAB or MPL) depict highly sophisticated 3D plots that are much more
> than I can need, which turn to be plotting of data onto a geographic
> (therefore, regular and 2D) grid and displaying the plot over a
> Basemap (usually, but not necessarily, using an Equirectangular
> projection) -- so that I can come up with something like the attached
> figure.
>
> To begin with, here are some general questions:
>
> 1) Can a plot like this one (but not necessarily identical) be done
> with MPL/Basemap from gridded data?
> 
Mauro: The answer is yes. It looks like a pcolor plot with missing 
data over the oceans, so you will probably have to use a masked array 
for the data with the ocean values masked.
> 2) For constructing the grid, I have to use the NumPy meshgrid()
> method, as the data are regularly spaced on a geographic grid. For
> example:
>
> import numpy
> import matplotlib.pyplot as plt
>
> coords = numpy.loadtxt('grid.dat')
> lon = coords[:,0]
> lat = coords[:,1]
> dat = coords[:,2]
> X, Y = numpy.meshgrid(lon, lat)
>
> where grid.dat is as follows (very simple dataset, just for
> demonstration purposes):
>
> -61.05 10.4 20
> -79.43 9.15 50
> -70.66 9.53 10
> -63.11 7.91 40
> -63.11 10.55 20
> -81.18 7.51 80
> -56.48 3.1 90
> -60.5 3.93 10
> -81.01 7.66 5
> -67.43 8.93 10
> -65.96 10.31 20
> -78.93 8.38 30
> -72.86 9.83 40
> -68.4 10.61 40
> -72.98 10.61 20
>
> The first two columns correspond to longitude, latitude, and the third
> correspond to the variable to be plotted onto the grid (species
> richness).
>
> The above script reads the data and generates the grid, but then, how
> can I display it on a 2D grid overlaid on a Basemap?
> 
Assuming that this is a regular grid (so that using meshgrid makes 
sense) you can
using pcolor:
m.pcolormesh(x,y,dat)
using contourf:
m.contourf(x,y,dat,clevs)
using imshow:
m.imshow(dat)
There are examples of all three included with basemap.
HTH,
-Jeff
> Well, as I mentioned above, this is the first part of a longer
> question (but I cannot pursue it first before solving these one
> first).
>
> Thanks in advance for any assistance you can provide.
>
> With best regards,
>
> 
>
> ------------------------------------------------------------------------
>
> ------------------------------------------------------------------------
>
> ------------------------------------------------------------------------------
> SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
> The future of the web can't happen without you. Join us at MIX09 to help
> pave the way to the Next Web now. Learn more and register at
> http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
> ------------------------------------------------------------------------
>
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
-- 
Jeffrey S. Whitaker Phone : (303)497-6313
NOAA/OAR/CDC R/PSD1 FAX : (303)497-6449
325 Broadway Boulder, CO, USA 80305-3328
From: Mauro C. <mau...@gm...> - 2008年12月09日 11:59:10
Attachments: wg2.gif
Dear ALL,
Good morning! Here am I again with the first (and perhaps simpler)
part of a potentially long question on plotting gridded data using MPL
(*and* Basemap).
Most examples I have found of plotting gridded data (using either
MATLAB or MPL) depict highly sophisticated 3D plots that are much more
than I can need, which turn to be plotting of data onto a geographic
(therefore, regular and 2D) grid and displaying the plot over a
Basemap (usually, but not necessarily, using an Equirectangular
projection) -- so that I can come up with something like the attached
figure.
To begin with, here are some general questions:
1) Can a plot like this one (but not necessarily identical) be done
with MPL/Basemap from gridded data?
2) For constructing the grid, I have to use the NumPy meshgrid()
method, as the data are regularly spaced on a geographic grid. For
example:
import numpy
import matplotlib.pyplot as plt
coords = numpy.loadtxt('grid.dat')
lon = coords[:,0]
lat = coords[:,1]
dat = coords[:,2]
X, Y = numpy.meshgrid(lon, lat)
where grid.dat is as follows (very simple dataset, just for
demonstration purposes):
-61.05 10.4 20
-79.43 9.15 50
-70.66 9.53 10
-63.11 7.91 40
-63.11 10.55 20
-81.18 7.51 80
-56.48 3.1 90
-60.5 3.93 10
-81.01 7.66 5
-67.43 8.93 10
-65.96 10.31 20
-78.93 8.38 30
-72.86 9.83 40
-68.4 10.61 40
-72.98 10.61 20
The first two columns correspond to longitude, latitude, and the third
correspond to the variable to be plotted onto the grid (species
richness).
The above script reads the data and generates the grid, but then, how
can I display it on a 2D grid overlaid on a Basemap?
Well, as I mentioned above, this is the first part of a longer
question (but I cannot pursue it first before solving these one
first).
Thanks in advance for any assistance you can provide.
With 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."

Showing 15 results of 15

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 によって変換されたページ (->オリジナル) /