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




Showing 14 results of 14

From: João L. S. <js...@fc...> - 2009年03月13日 22:39:23
per freem wrote:
> hi all,
> 
> what's the most efficient / preferred python way of parsing tab 
> separated data into arrays? for example if i have a file containing two 
Check out the python csv module. Documentation at
http://docs.python.org/library/csv.html
JLS
From: Timothée L. <tim...@lp...> - 2009年03月13日 22:24:20
Jeff Whitaker wrote:
> Jeff Whitaker wrote:
>> Timothée Lecomte wrote:
>>> Dear all,
>>>
>>> I am using matplotlib with a great pleasure, and I enjoy its 
>>> capabilities.
>>> I have recently attended a conference where the invited speaker 
>>> showed great visualizations of arrays from both experiments and 
>>> simulations. His plots were basically looking like those produced by 
>>> imshow, that is a luminance array rendered as a colormap image, but 
>>> with the additionnal use of a shading, which gives a really great 
>>> feeling to the image. You can feel the height of each part of the 
>>> image.
>>>
>>> I have tried to find what software could have produced such a plot, 
>>> and found the ReliefPlot function of Mathematica, which has 
>>> precisely this purpose : rendering a colormap image from an array 
>>> with a shading to give the perception of relief.
>>>
>>> The documentation and its examples are self-explanatory :
>>> http://reference.wolfram.com/mathematica/ref/ReliefPlot.html
>>> (look in particular at the first "neat example" at the bottom of 
>>> that page)
>>>
>>> The two "live" demonstrations illustrate this plot style quite well 
>>> too :
>>> http://demonstrations.wolfram.com/ReliefShadedElevationMap/
>>> http://demonstrations.wolfram.com/VoronoiImage/
>>>
>>> So here are my questions :
>>> Is there a trick to generate an image with such a shading in 
>>> matplotlib ?
>>> If not, do you know of a python tool that could help ?
>>> Where could I start if I want to code it myself in matplotlib ?
>>>
>>> Thanks for your help.
>>>
>>> Best regards,
>>>
>>> Timothée Lecomte
>>>
>>> 
>>
>> Timothée: There is nothing built-in, but it would be a nice thing to 
>> have. Here's a proof-of-concept hack that follows the approach used 
>> in the Generic Mapping Tools (explained here 
>> http://www.seismo.ethz.ch/gmt/doc/html/tutorial/node70.html), with 
>> some code borrowed from http://www.langarson.com.au/blog/?p=14. It's 
>> very rough, but if it looks promising to you I can try to polish it.
>>
>> -Jeff
>
> Found a bug, here's a fixed version.
>
> -Jeff
>
Hi Jeff,
Sure it looks promising ! The example you provided is very nice. I will 
try on my own data on Monday, and I'll let you know if it gives a good 
result too. Thank you very much for that very fast hack !
Best regards,
Timothée
From: per f. <per...@gm...> - 2009年03月13日 22:18:41
hi all,
what's the most efficient / preferred python way of parsing tab separated
data into arrays? for example if i have a file containing two columns one
corresponding to names the other numbers:
col1 \t col 2
joe \t 12.3
jane \t 155.0
i'd like to parse into an array() such that i can do: mydata[:, 0] and
mydata[:, 1] to easily access all the columns.
right now i can iterate through the file, parse it manually using the
split('\t') command and construct a list out of it, then convert it to
arrays. but there must be a better way?
also, my first column is just a name, and so it is variable in length -- is
there still a way to store it as an array so i can access: mydata[:, 0] to
get all the names (as a list)?
thank you.
From: Thomas R. <tho...@gm...> - 2009年03月13日 21:53:51
Thanks to both of you for your help! I had spotted the transform 
argument in imshow, but didn't manage to find any information about 
how to use it. The Affine2D method looks like it will help, so I 
should be all set now.
Thanks!
Thomas
On Mar 13, 2009, at 5:20 PM, Andrew Straw wrote:
> Eric Firing wrote:
>> Thomas Robitaille wrote:
>>> Hello,
>>>
>>> I was wondering whether there is a way to rotate a grayscale/
>>> colorscale when using imshow.
>>>
>>> I have been using PGPLOT (a fortran/c plotting library) for many 
>>> years
>>> now, and the equivalent to imshow is called PGGRAY (or PGIMAG). 
>>> One of
>>> the arguments this function takes is a 6-element array TR which is a
>>> transformation matrix. From the PGPLOT documentation:
>>>
>>> "The transformation matrix TR is used to calculate the world
>>> coordinates of the center of the "cell" that represents each array
>>> element. The world coordinates of the center of the cell 
>>> corresponding
>>> to array element A(I,J) are given by:
>>> X = TR(1) + TR(2)*I + TR(3)*J
>>> Y = TR(4) + TR(5)*I + TR(6)*J"
>>
>> You could do this with the Axes.pcolormesh method. You could start 
>> with
>> an unrotated grid (generated by meshgrid, for example), apply your
>> rotation, and use that transformed grid in pcolormesh. Note that
>> pcolormesh requires the grid for the cell boundaries, not centers.
>>
>
> It should work with imshow() as well if you can set the affine 
> component
> of the transform to the desired values. Which it looks like you can in
> Affine2D(). (The affine matrix is the elements of TR listed above, it
> appears.)
>
> I have not tried to do this, however -- just saying that I think it's
> possible.
>
> -Andrew
From: Thomas R. <tho...@gm...> - 2009年03月13日 21:46:50
It looks like rotation/translation should be easy to do with Affine2D, 
so I tried using it, but I can't seem to get it to work as expected - 
here is an example of how I am using it:
import numpy as np
from matplotlib.pyplot import *
from matplotlib.transforms import Affine2D
im = np.random.random((10,10))
tr = Affine2D().rotate_deg(45.)
fig = figure()
ax = fig.add_subplot(111)
ax.imshow(im,transform=tr)
fig.canvas.draw()
Am I doing something wrong?
Thanks!
Thomas
On Mar 13, 2009, at 5:20 PM, Andrew Straw wrote:
> Eric Firing wrote:
>> Thomas Robitaille wrote:
>>> Hello,
>>>
>>> I was wondering whether there is a way to rotate a grayscale/
>>> colorscale when using imshow.
>>>
>>> I have been using PGPLOT (a fortran/c plotting library) for many 
>>> years
>>> now, and the equivalent to imshow is called PGGRAY (or PGIMAG). 
>>> One of
>>> the arguments this function takes is a 6-element array TR which is a
>>> transformation matrix. From the PGPLOT documentation:
>>>
>>> "The transformation matrix TR is used to calculate the world
>>> coordinates of the center of the "cell" that represents each array
>>> element. The world coordinates of the center of the cell 
>>> corresponding
>>> to array element A(I,J) are given by:
>>> X = TR(1) + TR(2)*I + TR(3)*J
>>> Y = TR(4) + TR(5)*I + TR(6)*J"
>>
>> You could do this with the Axes.pcolormesh method. You could start 
>> with
>> an unrotated grid (generated by meshgrid, for example), apply your
>> rotation, and use that transformed grid in pcolormesh. Note that
>> pcolormesh requires the grid for the cell boundaries, not centers.
>>
>
> It should work with imshow() as well if you can set the affine 
> component
> of the transform to the desired values. Which it looks like you can in
> Affine2D(). (The affine matrix is the elements of TR listed above, it
> appears.)
>
> I have not tried to do this, however -- just saying that I think it's
> possible.
>
> -Andrew
From: Andrew S. <str...@as...> - 2009年03月13日 21:20:16
Eric Firing wrote:
> Thomas Robitaille wrote:
>> Hello,
>>
>> I was wondering whether there is a way to rotate a grayscale/ 
>> colorscale when using imshow.
>>
>> I have been using PGPLOT (a fortran/c plotting library) for many years 
>> now, and the equivalent to imshow is called PGGRAY (or PGIMAG). One of 
>> the arguments this function takes is a 6-element array TR which is a 
>> transformation matrix. From the PGPLOT documentation:
>>
>> "The transformation matrix TR is used to calculate the world 
>> coordinates of the center of the "cell" that represents each array 
>> element. The world coordinates of the center of the cell corresponding 
>> to array element A(I,J) are given by:
>> X = TR(1) + TR(2)*I + TR(3)*J
>> Y = TR(4) + TR(5)*I + TR(6)*J"
> 
> You could do this with the Axes.pcolormesh method. You could start with 
> an unrotated grid (generated by meshgrid, for example), apply your 
> rotation, and use that transformed grid in pcolormesh. Note that 
> pcolormesh requires the grid for the cell boundaries, not centers.
> 
It should work with imshow() as well if you can set the affine component
of the transform to the desired values. Which it looks like you can in
Affine2D(). (The affine matrix is the elements of TR listed above, it
appears.)
I have not tried to do this, however -- just saying that I think it's
possible.
-Andrew
From: Jeff W. <js...@fa...> - 2009年03月13日 21:10:08
Attachments: hillshade.py
Jeff Whitaker wrote:
> Timothée Lecomte wrote:
>> Dear all,
>>
>> I am using matplotlib with a great pleasure, and I enjoy its 
>> capabilities.
>> I have recently attended a conference where the invited speaker 
>> showed great visualizations of arrays from both experiments and 
>> simulations. His plots were basically looking like those produced by 
>> imshow, that is a luminance array rendered as a colormap image, but 
>> with the additionnal use of a shading, which gives a really great 
>> feeling to the image. You can feel the height of each part of the image.
>>
>> I have tried to find what software could have produced such a plot, 
>> and found the ReliefPlot function of Mathematica, which has precisely 
>> this purpose : rendering a colormap image from an array with a 
>> shading to give the perception of relief.
>>
>> The documentation and its examples are self-explanatory :
>> http://reference.wolfram.com/mathematica/ref/ReliefPlot.html
>> (look in particular at the first "neat example" at the bottom of that 
>> page)
>>
>> The two "live" demonstrations illustrate this plot style quite well 
>> too :
>> http://demonstrations.wolfram.com/ReliefShadedElevationMap/
>> http://demonstrations.wolfram.com/VoronoiImage/
>>
>> So here are my questions :
>> Is there a trick to generate an image with such a shading in 
>> matplotlib ?
>> If not, do you know of a python tool that could help ?
>> Where could I start if I want to code it myself in matplotlib ?
>>
>> Thanks for your help.
>>
>> Best regards,
>>
>> Timothée Lecomte
>>
>> 
>
> Timothée: There is nothing built-in, but it would be a nice thing to 
> have. Here's a proof-of-concept hack that follows the approach used 
> in the Generic Mapping Tools (explained here 
> http://www.seismo.ethz.ch/gmt/doc/html/tutorial/node70.html), with 
> some code borrowed from http://www.langarson.com.au/blog/?p=14. It's 
> very rough, but if it looks promising to you I can try to polish it.
>
> -Jeff
Found a bug, here's a fixed version.
-Jeff
-- 
Jeffrey S. Whitaker Phone : (303)497-6313
Meteorologist FAX : (303)497-6449
NOAA/OAR/PSD R/PSD1 Email : Jef...@no...
325 Broadway Office : Skaggs Research Cntr 1D-113
Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg
From: Eric F. <ef...@ha...> - 2009年03月13日 20:48:40
Thomas Robitaille wrote:
> Hello,
> 
> I was wondering whether there is a way to rotate a grayscale/ 
> colorscale when using imshow.
> 
> I have been using PGPLOT (a fortran/c plotting library) for many years 
> now, and the equivalent to imshow is called PGGRAY (or PGIMAG). One of 
> the arguments this function takes is a 6-element array TR which is a 
> transformation matrix. From the PGPLOT documentation:
> 
> "The transformation matrix TR is used to calculate the world 
> coordinates of the center of the "cell" that represents each array 
> element. The world coordinates of the center of the cell corresponding 
> to array element A(I,J) are given by:
> X = TR(1) + TR(2)*I + TR(3)*J
> Y = TR(4) + TR(5)*I + TR(6)*J"
You could do this with the Axes.pcolormesh method. You could start with 
an unrotated grid (generated by meshgrid, for example), apply your 
rotation, and use that transformed grid in pcolormesh. Note that 
pcolormesh requires the grid for the cell boundaries, not centers.
Eric
> 
> This is actually the same as the ImageMatrix element in the Postscript 
> language:
> 
> "ImageMatrix array (Required) An array of six numbers defining a 
> transformation from user
> space to image space." (http://www.adobe.com/devnet/postscript/pdfs/PLRM.pdf 
> , page 298)
> 
> This allows arbitrary rotation/translation of the image to plotting 
> without any loss in quality for vector graphics formats (EPS, PDF, SVG).
> 
> So far, I have found that imshow has an 'extend' keyword, which is the 
> equivalent of four of the matrix elements, but there is no way to 
> specify the rotation. Is there such a feature in matplotlib already? 
> If not, would it be possible to implement it?
> 
> Just to be clear, I am not talking about rotating with some kind of 
> interpolation, which would degrade the image (this can be done with 
> PIL). What I want is to be able to specify a transformation matrix 
> which includes rotation, which means that there is no resampling done 
> if I save my plot in a vector graphics format.
> 
> Thanks in advance for any help!
> 
> Thomas
> 
> ------------------------------------------------------------------------------
> Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
> powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
> easily build your RIAs with Flex Builder, the Eclipse(TM)based development
> software that enables intelligent coding and step-through debugging.
> Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: Thomas R. <tho...@gm...> - 2009年03月13日 20:35:53
Hello,
I was wondering whether there is a way to rotate a grayscale/ 
colorscale when using imshow.
I have been using PGPLOT (a fortran/c plotting library) for many years 
now, and the equivalent to imshow is called PGGRAY (or PGIMAG). One of 
the arguments this function takes is a 6-element array TR which is a 
transformation matrix. From the PGPLOT documentation:
"The transformation matrix TR is used to calculate the world 
coordinates of the center of the "cell" that represents each array 
element. The world coordinates of the center of the cell corresponding 
to array element A(I,J) are given by:
X = TR(1) + TR(2)*I + TR(3)*J
Y = TR(4) + TR(5)*I + TR(6)*J"
This is actually the same as the ImageMatrix element in the Postscript 
language:
"ImageMatrix array (Required) An array of six numbers defining a 
transformation from user
space to image space." (http://www.adobe.com/devnet/postscript/pdfs/PLRM.pdf 
, page 298)
This allows arbitrary rotation/translation of the image to plotting 
without any loss in quality for vector graphics formats (EPS, PDF, SVG).
So far, I have found that imshow has an 'extend' keyword, which is the 
equivalent of four of the matrix elements, but there is no way to 
specify the rotation. Is there such a feature in matplotlib already? 
If not, would it be possible to implement it?
Just to be clear, I am not talking about rotating with some kind of 
interpolation, which would degrade the image (this can be done with 
PIL). What I want is to be able to specify a transformation matrix 
which includes rotation, which means that there is no resampling done 
if I save my plot in a vector graphics format.
Thanks in advance for any help!
Thomas
From: Jeff W. <js...@fa...> - 2009年03月13日 20:03:09
Attachments: hillshade.py
Timothée Lecomte wrote:
> Dear all,
>
> I am using matplotlib with a great pleasure, and I enjoy its capabilities.
> I have recently attended a conference where the invited speaker showed 
> great visualizations of arrays from both experiments and simulations. 
> His plots were basically looking like those produced by imshow, that is 
> a luminance array rendered as a colormap image, but with the additionnal 
> use of a shading, which gives a really great feeling to the image. You 
> can feel the height of each part of the image.
>
> I have tried to find what software could have produced such a plot, and 
> found the ReliefPlot function of Mathematica, which has precisely this 
> purpose : rendering a colormap image from an array with a shading to 
> give the perception of relief.
>
> The documentation and its examples are self-explanatory :
> http://reference.wolfram.com/mathematica/ref/ReliefPlot.html
> (look in particular at the first "neat example" at the bottom of that page)
>
> The two "live" demonstrations illustrate this plot style quite well too :
> http://demonstrations.wolfram.com/ReliefShadedElevationMap/
> http://demonstrations.wolfram.com/VoronoiImage/
>
> So here are my questions :
> Is there a trick to generate an image with such a shading in matplotlib ?
> If not, do you know of a python tool that could help ?
> Where could I start if I want to code it myself in matplotlib ?
>
> Thanks for your help.
>
> Best regards,
>
> Timothée Lecomte
>
> 
Timothée: There is nothing built-in, but it would be a nice thing to have. Here's a proof-of-concept hack that follows the approach used in the Generic Mapping Tools (explained here http://www.seismo.ethz.ch/gmt/doc/html/tutorial/node70.html), with some code borrowed from http://www.langarson.com.au/blog/?p=14. It's very rough, but if it looks promising to you I can try to polish it.
-Jeff
-- 
Jeffrey S. Whitaker Phone : (303)497-6313
Meteorologist FAX : (303)497-6449
NOAA/OAR/PSD R/PSD1 Email : Jef...@no...
325 Broadway Office : Skaggs Research Cntr 1D-113
Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg
From: Jeff W. <js...@fa...> - 2009年03月13日 15:54:54
James Boyle wrote:
> Jeff,
>
> This is something I have noticed recently. If I set lon_0 = 180. using 
> the robin projection , the parallels from 0 to 180 are drawn thicker 
> than those from 180 to 360.
> Perhaps the 0 to 180 are drawn twice - with some small offset - due 
> some wraparound problem.
> Enclosed is some code illustrating the problem and the pngs.
> It is not a glaring difference, but I think real. It also shows up if 
> you look carefully at the output from simpletest.py in your examples.
>
> basemap .99.1 matplotlib 0.98.3 OS X 10.4
> --Jim
>
> m = basemap.Basemap(resolution='c',projection='robin',lon_0=180.)
> parallels = numpy.arange(-90.,90.,30.)
> m.drawparallels(parallels,labels=[1,0,0,0],color='r')
> pylab.title('lon_0=180')
> pylab.savefig('lon_0-180')
> pylab.clf()
>
> m = basemap.Basemap(resolution='c',projection='robin',lon_0=0.)
> parallels = numpy.arange(-90.,90.,30.)
> m.drawparallels(parallels,labels=[1,0,0,0],color='r')
> pylab.title('lon_0=0')
> pylab.savefig('lon_0-0')
> pylab.clf()
>
Jim: I can't reproduce this, so I suspect it's been fixed since basemap 
0.99.1. Can you upgrade and let me know whether that fixes it for you?
-Jeff
(P.S. CC'ing matplotlib-users)
> ------------------------------------------------------------------------
>
>
>
> ------------------------------------------------------------------------
>
-- 
Jeffrey S. Whitaker Phone : (303)497-6313
Meteorologist FAX : (303)497-6449
NOAA/OAR/PSD R/PSD1 Email : Jef...@no...
325 Broadway Office : Skaggs Research Cntr 1D-113
Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg
From: Karen T. <kmt...@gm...> - 2009年03月13日 14:43:15
I am using matplotlib's object-oriented API to dynamically generate some
graphs served by a web site. The web site is built with Django and I have
generally followed the cookbook example I found here:
http://www.scipy.org/Cookbook/Matplotlib/Django for serving matplotlib
figures under Django. Specifically my code looks like this:
from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
from matplotlib.figure import Figure
def generate_png(request, f, year, cid, pid, ic):
 # ...snipped code that generates the data to graph...
 fig = Figure()
 ax = fig.add_subplot(111)
 ax.set_title(fig_title)
 ax.set_xlabel("Score")
 ax.set_ylabel("Frequency")
 n, bins2, patches = ax.hist(vals, bins, facecolor='blue',
edgecolor='blue')
 if x is not None:
 patches[x].set_facecolor('red')
 patches[x].set_edgecolor('red')
 fig.legend((patches[x],), ('%s (%d)' % (cname, cval),), 'lower
left')
 canvas = FigureCanvas(fig)
 canvas.print_png(f)
 # ... snip remainder ...
This works fine, except when I run it under a multi-threaded web server
(Apache with mod_wsgi in daemon mode with multi-threaded processes) it
sometimes (not always) fails with this traceback:
 File "/home/kmt/django/Django-1.1-alpha-1/django/core/handlers/base.py",
line 86, in get_response
 response = callback(request, *callback_args, **callback_kwargs)
 File "/home/kmt/software/web/xword/acpt/views.py", line 321, in get_png
 response = generate_png(request, f, year, cid, pid, ic)
 File "/home/kmt/software/web/xword/acpt/views.py", line 308, in
generate_png
 canvas.print_png(f)
 File "/usr/lib/python2.5/site-packages/matplotlib/backends/backend_agg.py",
line 305, in print_png
 FigureCanvasAgg.draw(self)
 File "/usr/lib/python2.5/site-packages/matplotlib/backends/backend_agg.py",
line 261, in draw
 self.figure.draw(self.renderer)
 File "/usr/lib/python2.5/site-packages/matplotlib/figure.py", line 765, in
draw
 legend.draw(renderer)
 File "/usr/lib/python2.5/site-packages/matplotlib/legend.py", line 215, in
draw
 t.draw(renderer)
 File "/usr/lib/python2.5/site-packages/matplotlib/text.py", line 329, in
draw
 ismath=self.is_math_text(line))
 File "/usr/lib/python2.5/site-packages/matplotlib/backends/backend_agg.py",
line 113, in draw_text
 self._renderer.draw_text_image(font.get_image(), int(x), int(y) + 1,
angle, gc)
RuntimeError: You must call .set_text() before .get_image()
I'm not at all familiar with the internals (truly I'm barely familiar with
the public APIs) of matplotlib but it appears from this exception that
internally there's a 'font' object being shared between threads here, such
that one thread can come in and change the font state resulting in a
subsequent error in a different thread that was also in the middle of using
that font object? If I protect that block of code above with a thread lock
so that only one thread is allowed in at a time, the problem goes away.
For reference I'm using the latest matplotlib available in the Ubuntu
Intrepid (8.10) repositories, which looks to be 0.98.3. In a brief scan I
didn't see anything relevant listed in the "what's new" page for 0.98.4 (and
can't find a "what's new in 0.98.5" on the matplotlib web site though that
is what is listed as most recent?). Nor can I find anything that looks
similar logged as a bug in the tracker.
Is there something (besides bracketing all access to the matplotlib code
with a thread mutex) that I should be doing to make my use of matplotlib
thread safe or does it seem like there's a multi-threading bug in matplotlib
here?
Thanks for any pointers,
Karen
From: Timothée L. <tim...@lp...> - 2009年03月13日 11:30:30
Dear all,
I am using matplotlib with a great pleasure, and I enjoy its capabilities.
I have recently attended a conference where the invited speaker showed 
great visualizations of arrays from both experiments and simulations. 
His plots were basically looking like those produced by imshow, that is 
a luminance array rendered as a colormap image, but with the additionnal 
use of a shading, which gives a really great feeling to the image. You 
can feel the height of each part of the image.
I have tried to find what software could have produced such a plot, and 
found the ReliefPlot function of Mathematica, which has precisely this 
purpose : rendering a colormap image from an array with a shading to 
give the perception of relief.
The documentation and its examples are self-explanatory :
http://reference.wolfram.com/mathematica/ref/ReliefPlot.html
(look in particular at the first "neat example" at the bottom of that page)
The two "live" demonstrations illustrate this plot style quite well too :
http://demonstrations.wolfram.com/ReliefShadedElevationMap/
http://demonstrations.wolfram.com/VoronoiImage/
So here are my questions :
Is there a trick to generate an image with such a shading in matplotlib ?
If not, do you know of a python tool that could help ?
Where could I start if I want to code it myself in matplotlib ?
Thanks for your help.
Best regards,
Timothée Lecomte
-- 
Laboratoire Pierre Aigrain,
École Normale Supérieure
24, rue Lhomond
75005 Paris
From: Jeff W. <js...@fa...> - 2009年03月13日 02:26:36
Hatch, Sara J wrote:
> Jeff,
>
> My plan was to use the orthographic projection to represent the Moon (hence the 1737.4 km radius) and to plot a spacecraft trajectory around it. If I had read the rsphere documentation past the first half sentence I would have noticed that it was in meters instead of kilometers, sorry about that. Once I implemented this change, the horizontal lines go away.
> 
Sara: OK, great.
> Regarding the origin location: I have my spacecraft trajectory calculated with the origin being coincident with the center of the Moon. I can easily translate my coordinates to work with the origin not being the center of the projection, but would it be possible to implement some way to change where the origin is on the projection?
> 
No, sorry - there's no easy way to do that.
-Jeff
> Thanks,
> Sara
>
>
>
> -----Original Message-----
> From: Jeff Whitaker [mailto:js...@fa...] 
> Sent: Thursday, March 12, 2009 4:05 PM
> To: Hatch, Sara J
> Cc: mat...@li...
> Subject: Re: [Matplotlib-users] Erroneous Horizontal Lines when Using Basemap
>
> Hatch, Sara J wrote:
> 
>> Matplotlib Folks,
>>
>> I tried to use the orthographic projection in the basemap toolkit and 
>> I'm finding that the parallel lines are not behaving correctly, i.e., 
>> there are horizontal lines connecting the left and right side of the 
>> map boundary where a curved latitude line intersects the map boundary. 
>> I've included a sample script below and a figure illustrating the problem.
>>
>> import pylab
>>
>> import mpl_toolkits.basemap as basemap
>>
>> ortho = 
>> basemap.Basemap(projection='ortho',lon_0=0,lat_0=50,rsphere=1737.4)
>>
>> ortho.drawparallels(pylab.arange(-90,90,30))
>>
>> ortho.drawmeridians(pylab.arange(0,360,30))
>>
>> ortho.drawmapboundary(fill_color='w')
>>
>> In addition, how do I change the x/y coordinates the center of the 
>> projection to be (0,0)? With the above code, the center of the 
>> bounding circle is at (1737.4,1737.4).
>>
>> Thanks for the help,
>>
>> Sara
>>
>> 
> Sara: If you take out the rsphere=1734.4 (thereby using the default 
> value of 6370997), the jumpy lines go away. rsphere=1734.4 means assume 
> the earth is a perfect sphere with a radius of 1734.4 meters. That's an 
> awfully small earth - I think the jumpy lines are a result of roundoff 
> errors in the map projection calculation for very small spheres. Still, 
> that shouldn't happen, so I will look into it.
>
> Regarding the x/y coordinate of the middle of the plot - Basemap assigns 
> the lower left corner of the map projection region an x/y value of 0,0 
> for most map projections.
>
> -Jeff
>
> 
1 message has been excluded from this view by a project administrator.

Showing 14 results of 14

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