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



Showing 9 results of 9

From: Jeff W. <js...@fa...> - 2005年08月23日 19:09:31
Attachments: pylab.patch figure.patch
Eric Firing wrote:
>
>>
>> Thanks Eric - I just wanted to make sure I wasn't missing some 
>> obvious way to do it.
>
>
>
> Jeff,
>
> A possible trick would be to make a very skinny subplot (using custom 
> sizing and positioning) and use contourf itself to make the colorbar 
> in it. I think this is actually the way I am doing it in Matlab. (A 
> colleague and I greatly customized the Matlab colorbar for this sort 
> of thing a long time ago.)
>
> Eric
Eric/Phil: Here is a hack that produces colorbars with discrete contour 
intervals for use with contourf. It's in the form of a patch for 
pylab.py and figure.py (based on 0.83.2). When pylab.colorbar is 
called, it checks to see if the current image was created by contourf, 
and if so calls figure.colobar_contourf (which uses contourf instead of 
imshow to make the colorbar). Here's a test script:
"""test script for contourf colorbar"""
from pylab import *
def func3(x,y):
 return (1- x/2 + x**5 + y**3)*exp(-x**2-y**2)
dx, dy = 0.05, 0.05
X,Y = meshgrid(arange(-3.0,3.0001,dx),arange(-3.0,3.0001,dy))
Z = func3(X, Y)
levels = linspace(-1.2,1.2,13)
l,c = contour (X, Y, Z, levels, linewidths=0.5, colors='k')
clabel(c,l,fmt='%4.2f')
l,c = contourf(X, Y, Z, levels, cmap=cm.jet)
colorbar(tickfmt='%4.2f',orientation='horizontal') # horiz colorbar
colorbar(tickfmt='%4.2f',orientation='vertical') # vert colorbar
axis([-3,3,-3,3])
show()
This doesn't address the other two of Phil's requests (triangles at the 
ends, and constant intervals on the colorbar for non-constant contour 
levels), but I think it's a start.
-Jeff
-- 
Jeffrey S. Whitaker Phone : (303)497-6313
Meteorologist FAX : (303)497-6449
NOAA/OAR/CDC R/CDC1 Email : Jef...@no...
325 Broadway Office : Skaggs Research Cntr 1D-124
Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg
From: Yves M. <ym...@gr...> - 2005年08月23日 17:10:06
Hi All,
I'm striving to understand how I ca stuff a file object (e.g. StringIO) to
print_figure for an Agg backend. backend_agg.py states : "If filename is a
fileobject, write png to file object (thus you can, for example, write the png
to stdout".
I tried :
 canvas = FigureCanvasAgg(fig)
 data = StringIO.StringIO()
 canvas.print_figure(data, dpi=150)
 return data.get_value()
But that returns an error from backend_agg.py line 383 (matplotlib v. - 0.76) :
StringIO instance has no attribute 'rfind'.
I've decided to use tempfile, but that leads to something hefty and I hate
writing to disk :
 tempplotfilename = tempfile.mkstemp(suffix='.png')
 canvas.print_figure(tempplotfilename[1], dpi=150)
 data = os.read(tempplotfilename[0],os.fstat(tempplotfilename[0]).st_size)
# self.REQUEST.RESPONSE.setHeader('Content-Length',
os.fstat(tempplotfilename[0]).st_size)
# self.REQUEST.RESPONSE.setHeader('Pragma', 'no-cache')
 self.REQUEST.RESPONSE.setHeader('Content-Type', 'image/png')
# os.close(tempplotfilename[0])
# os.unlink(tempplotfilename[1])
 return data
Can this be done ?
Thank you,
Yves Moisan
From: Alan G I. <ai...@am...> - 2005年08月23日 13:44:31
On 2005年8月23日, T) Sascha GL apparently wrote: 
> Never mind... I found the solution. 
This list is more useful if the solution is actually posted.
Cheers,
Alan Isaac
From: John H. <jdh...@ac...> - 2005年08月23日 13:25:53
>>>>> "Sascha" == Sascha GL <Sas...@gm...> writes:
 Sascha> Never mind... I found the solution. Thanks. Sascha
And the answer, for the archives.... ?
JDH
Never mind... I found the solution. Thanks.
Sascha
-- 
5 GB Mailbox, 50 FreeSMS http://www.gmx.net/de/go/promail
+++ GMX - die erste Adresse für Mail, Message, More +++
From: Sascha G. <Sas...@gm...> - 2005年08月23日 06:20:16
I realize that this is probably not the appropriate place to ask this
question but it may be related to using matplotlib's pylab interface. The
issue is that when I print an array, I get only the first 300 elements and
then " + XX more elements". Is there a way to get rid of this behavior? I'd
guess so because when using Numeric directly, the complete array is printed.
Thanks in advance for your help.
Sascha
-- 
5 GB Mailbox, 50 FreeSMS http://www.gmx.net/de/go/promail
+++ GMX - die erste Adresse für Mail, Message, More +++
From: Phil R. <pj...@uc...> - 2005年08月23日 02:02:59
Attachments: example.png
Just for completness I will attach the figure this time.
Phil
On Mon, Aug 22, 2005 at 02:02:57PM -1000, Eric Firing wrote:
> Phil Rasch wrote:
> >On Mon, Aug 22, 2005 at 12:55:16PM -1000, Eric Firing wrote:
> >
> >>(from phil:)
> >
> >.... stuff deleted ......
> >
> >>Phil, Jeff,
> >>
> >>Yes, the present colorbar is designed for use with images, not with 
> >>contourf, and fixing it (or making a new one) is something I have wanted 
> >>to do for quite a while. I just haven't gotten to it yet. Prompted by 
> >>your two emails, maybe I can at least take a close look during the next 
> >>week to see what it would take. It might be easy--probably is. No 
> >>promises yet, though.
> >>
> >>Eric
> >
> >
> >Thanks Eric,
> >
> >I also believe it should be easy to do. But it is better done by
> >somebody more familiar with matplotlib and python than I. I have
> >written such codes for other languages but need more practice before
> >I could do it elegantly in python.
> >
> >As long as you are digging around in there, can I have you think about
> >another couple features? 
> >
> >1) The best colorbars in my mind have "triangles" at the endpoints
> >that indicate the color for the region higher than the highest
> >contour, and lower than the lowest contours. This allows one to label
> >only the meaningful boundaries and not specify how much above or below
> >those regions.
> >
> >2) I frequently need to set contour intervals (the filled region
> >boundaries) to be approximately logarithmic. But I dont want to have
> >these filled regions occupy a fraction of the colorbar proportional to
> >their fraction of the total interval. I want each region to be equal
> >area on the colorbar. 
> >
> >An example of these features can be seen in the attached PNG figure
> >that I created in Yorick with a colorbar code I wrote. I havent tried
> >for beauty, but these figure are OK for for working plots. You can see
> >the point for the unequal contour intervals in the difference plot at
> >the bottom.
> >
> >For the codes I wrote this necessitated supplying arguments to the
> >colorbar function like....
> >
> >colorbar(levs, colors)
> >where levels was an N element array, and colors was an N+1 element
> >list containing color info for each filled region. 
> >
> >Thanks for listening.
> >
> >Phil
> >
-- 
Phil Rasch, Climate Modeling Section, National Center for Atmospheric Research
Mail --> P.O. Box 3000, Boulder CO 80307 
Shipping --> 1850 Table Mesa Dr, Boulder, CO 80305
email: pj...@uc..., Web: http://www.cgd.ucar.edu/cms/pjr Phone: 303-497-1368, FAX: 303-497-1324 
From: Eric F. <ef...@ha...> - 2005年08月23日 00:06:01
Phil,
> 
> As long as you are digging around in there, can I have you think about
> another couple features? 
OK.
> 
> An example of these features can be seen in the attached PNG figure
I think you forgot to attach the figure--I didn't see it. Your 
description is pretty clear, though.
Eric
From: Eric F. <ef...@ha...> - 2005年08月23日 00:03:44
Phil Rasch wrote:
> On Mon, Aug 22, 2005 at 12:55:16PM -1000, Eric Firing wrote:
> 
>>(from phil:)
> 
> .... stuff deleted ......
> 
>>Phil, Jeff,
>>
>>Yes, the present colorbar is designed for use with images, not with 
>>contourf, and fixing it (or making a new one) is something I have wanted 
>>to do for quite a while. I just haven't gotten to it yet. Prompted by 
>>your two emails, maybe I can at least take a close look during the next 
>>week to see what it would take. It might be easy--probably is. No 
>>promises yet, though.
>>
>>Eric
> 
> 
> Thanks Eric,
> 
> I also believe it should be easy to do. But it is better done by
> somebody more familiar with matplotlib and python than I. I have
> written such codes for other languages but need more practice before
> I could do it elegantly in python.
> 
> As long as you are digging around in there, can I have you think about
> another couple features? 
> 
> 1) The best colorbars in my mind have "triangles" at the endpoints
> that indicate the color for the region higher than the highest
> contour, and lower than the lowest contours. This allows one to label
> only the meaningful boundaries and not specify how much above or below
> those regions.
> 
> 2) I frequently need to set contour intervals (the filled region
> boundaries) to be approximately logarithmic. But I dont want to have
> these filled regions occupy a fraction of the colorbar proportional to
> their fraction of the total interval. I want each region to be equal
> area on the colorbar. 
> 
> An example of these features can be seen in the attached PNG figure
> that I created in Yorick with a colorbar code I wrote. I havent tried
> for beauty, but these figure are OK for for working plots. You can see
> the point for the unequal contour intervals in the difference plot at
> the bottom.
> 
> For the codes I wrote this necessitated supplying arguments to the
> colorbar function like....
> 
> colorbar(levs, colors)
> where levels was an N element array, and colors was an N+1 element
> list containing color info for each filled region. 
> 
> Thanks for listening.
> 
> Phil
> 
1 message has been excluded from this view by a project administrator.

Showing 9 results of 9

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