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






Showing 4 results of 4

From: Eric F. <ef...@ha...> - 2006年12月06日 19:48:43
Rob,
This is now in svn, for pcolor only, not for pcolormesh. Please check 
it out. If everything is OK I can add it to pcolormesh as well 
(although pcolormesh still has a deeply-buried bug such that it does not 
work with alpha != 1).
Eric
Robert Hetland wrote:
> 
> I would like to propose expanding the inputs of pcolor to take vectors. 
> Often, you have x and y independent (seperable), and you don't want to 
> go on constructing an x array of redundant values. Actually, in NumPy 
> it is not straightforward to do this with resize if your variable is in 
> the first dimension like time (well, there is meshgrid, but you would 
> only use it for plotting, and with two vectors -- see below). Since 
> NumPy makes such heavy use of array broadcasting, it is not necessary.
> 
> I think MPL should follow the spirit of array broadcasting, and make it 
> such that:
> 
> x = arange(10)
> y = arange(30)
> z = rand(30,10)
> pcolor (x, y, z)
> 
> will work as expected. Perhaps, we could require a NewAxis in the right 
> places, but it would also make sense without. You should also be able to 
> send in just one vector. Consider
> 
> x,y = meshgrid(arange(10), arange(30))
> y = y + random.normal(size=y.shape)
> z = random.random(y.shape)
> pcolor (x, y, z)
> % but x is still essentially just arange(10)
> pcolor(arange(10), y, z)
> 
> What do you all think?
> 
> -Rob.
> 
> 
> -----
> Rob Hetland, Assistant Professor
> Dept of Oceanography, Texas A&M University
> p: 979-458-0096, f: 979-845-6331
> e: he...@ta..., w: http://pong.tamu.edu
> 
From: Tom D. <tom...@al...> - 2006年12月06日 17:11:26
Sorry meant to send this to the whole list:
----------------------------
John,
Thanks for the fix. After reading Eric's email I started to question
my profiling results but I still (without your fix) seem to see a
significant time when in Artist when generating large volumes of
graphs. I need to rebuild my matplotlib against svn and test your fix
now to see if that solves the problem.
Thanks for your help.
--Tom
On 12/5/06, John Hunter <jdh...@ac...> wrote:
> >>>>> "Christopher" == Christopher Barker <Chr...@no...> writes:
>
> Christopher> This sounds like a job for properties! make
> Christopher> _transform a property, and code that gets and sets it
> Christopher> directly should still work. though People that were
> Christopher> accessing an underscored name directly should expect
> Christopher> this kind of problem.
>
> The matplotlib artist kwarg properties act like python properties or
> enthought traits, with some advantages and disadvantages over each
> (mostly disadvantages, alas). We've discussed migrating to one or
> another over the years, but haven't bitten the bullet. At each point
> it's easier to extend the exiting implementation than refactor the
> whole bit; the tyranny of small decisions.
>
> Here are some of the pros and cons as I see them of enthought traits
> vs python properties
>
> Pros:
> * compatibility with the rest of the enthought tool suite
> * built in observer pattern
> * automatic UI for wx users
> * performance is better than python properties last time I looked
> * matplotlib ships with enthought traits built in
>
> Cons:
> * smaller user base than python properties may imply
> fewer 3rd party enhancements, less support, etc
> * we have to maintain our copy of enthought traits to keep it
> current and building or require an additional dependency
>
> I spent some time working on matplotlib rc properties as enthought
> traits as a precursor to porting matplotlib properties to traits.
> Here is some example code showing how to define some representative rc
> properties and construct a matplotlib artist using traits. Because
> matplotlib ships with enthought traits already, you can run this
> script with just matplotlib. Unfortunately, we do not ship the ex UI
> component so you can't test that part. I'm a bit of a traits newbie
> so there are probably better ways to do what I have done below.
>
> import sys, os, re
> import matplotlib.enthought.traits as traits
> from matplotlib.cbook import is_string_like
> from matplotlib.artist import Artist
>
> doprint = True
> flexible_true_trait = traits.Trait(
> True,
> { 'true': True, 't': True, 'yes': True, 'y': True, 'on': True, True: True,
> 'false': False, 'f': False, 'no': False, 'n': False, 'off': False, False: False
> } )
> flexible_false_trait = traits.Trait( False, flexible_true_trait )
>
> colors = {
> 'c' : '#00bfbf',
> 'b' : '#0000ff',
> 'g' : '#008000',
> 'k' : '#000000',
> 'm' : '#bf00bf',
> 'r' : '#ff0000',
> 'w' : '#ffffff',
> 'y' : '#bfbf00',
> 'gold' : '#FFD700',
> 'peachpuff' : '#FFDAB9',
> 'navajowhite' : '#FFDEAD',
> }
>
> def hex2color(s):
> "Convert hex string (like html uses, eg, #efefef) to a r,g,b tuple"
> return tuple([int(n, 16)/255.0 for n in (s[1:3], s[3:5], s[5:7])])
>
> class RGBA(traits.HasTraits):
> # r,g,b,a in the range 0-1 with default color 0,0,0,1 (black)
> r = traits.Range(0., 1., 0.)
> g = traits.Range(0., 1., 0.)
> b = traits.Range(0., 1., 0.)
> a = traits.Range(0., 1., 1.)
> def __init__(self, r=0., g=0., b=0., a=1.):
> self.r = r
> self.g = g
> self.b = b
> self.a = a
> def __repr__(self):
> return 'r,g,b,a = (%1.2f, %1.2f, %1.2f, %1.2f)'%\
> (self.r, self.g, self.b, self.a)
>
> def tuple_to_rgba(ob, name, val):
> tup = [float(x) for x in val]
> if len(tup)==3:
> r,g,b = tup
> return RGBA(r,g,b)
> elif len(tup)==4:
> r,g,b,a = tup
> return RGBA(r,g,b,a)
> else:
> raise ValueError
> tuple_to_rgba.info = 'a RGB or RGBA tuple of floats'
>
> def hex_to_rgba(ob, name, val):
> rgx = re.compile('^#[0-9A-Fa-f]{6}$')
>
> if not is_string_like(val):
> raise TypeError
> if rgx.match(val) is None:
> raise ValueError
> r,g,b = hex2color(val)
> return RGBA(r,g,b,1.0)
> hex_to_rgba.info = 'a hex color string'
>
> def colorname_to_rgba(ob, name, val):
> hex = colors[val.lower()]
> r,g,b = hex2color(hex)
> return RGBA(r,g,b,1.0)
> colorname_to_rgba.info = 'a named color'
>
> def float_to_rgba(ob, name, val):
> val = float(val)
> return RGBA(val, val, val, 1.)
> float_to_rgba.info = 'a grayscale intensity'
>
>
>
> Color = traits.Trait(RGBA(), float_to_rgba, colorname_to_rgba, RGBA,
> hex_to_rgba, tuple_to_rgba)
>
> def file_exists(ob, name, val):
> fh = file(val, 'r')
> return val
>
> def path_exists(ob, name, val):
> os.path.exists(val)
> linestyles = ('-', '--', '-.', ':', 'steps', 'None')
> TICKLEFT, TICKRIGHT, TICKUP, TICKDOWN = range(4)
> linemarkers = (None, '.', ',', 'o', '^', 'v', '<', '>', 's',
> '+', 'x', 'd', 'D', '|', '_', 'h', 'H',
> 'p', '1', '2', '3', '4',
> TICKLEFT,
> TICKRIGHT,
> TICKUP,
> TICKDOWN,
> 'None'
> )
>
> class LineRC(traits.HasTraits):
> linewidth = traits.Float(0.5)
> linestyle = traits.Trait(*linestyles)
> color = Color
> marker = traits.Trait(*linemarkers)
> markerfacecolor = Color
> markeredgecolor = Color
> markeredgewidth = traits.Float(0.5)
> markersize = traits.Float(6)
> antialiased = flexible_true_trait
> data_clipping = flexible_false_trait
>
> class PatchRC(traits.HasTraits):
> linewidth = traits.Float(1.0)
> facecolor = Color
> edgecolor = Color
> antialiased = flexible_true_trait
>
> timezones = 'UTC', 'US/Central', 'ES/Eastern' # fixme: and many more
> backends = ('GTKAgg', 'Cairo', 'FltkAgg', 'GD', 'GDK', 'GTK', 'Agg',
> 'GTKCairo', 'Paint', 'PS', 'SVG', 'Template', 'TkAgg',
> 'WX')
>
> class RC(traits.HasTraits):
> backend = traits.Trait(*backends)
> numerix = traits.Trait('Numeric', 'numarray')
> interactive = flexible_false_trait
> toolbar = traits.Trait('toolbar2', 'classic', None)
> timezone = traits.Trait(*timezones)
> lines = traits.Trait(LineRC())
> patch = traits.Trait(PatchRC())
>
> rc = RC()
> rc.lines.color = 'r'
> if doprint:
> print 'RC'
> rc.print_traits()
> print 'RC lines'
> rc.lines.print_traits()
> print 'RC patches'
> rc.patch.print_traits()
>
>
> class Patch(Artist, traits.HasTraits):
> linewidth = traits.Float(0.5)
> facecolor = Color
> fc = facecolor
> edgecolor = Color
> fill = flexible_true_trait
> def __init__(self,
> edgecolor=None,
> facecolor=None,
> linewidth=None,
> antialiased = None,
> fill=1,
> **kwargs
> ):
> Artist.__init__(self)
>
> if edgecolor is None: edgecolor = rc.patch.edgecolor
> if facecolor is None: facecolor = rc.patch.facecolor
> if linewidth is None: linewidth = rc.patch.linewidth
> if antialiased is None: antialiased = rc.patch.antialiased
>
> self.edgecolor = edgecolor
> self.facecolor = facecolor
> self.linewidth = linewidth
> self.antialiased = antialiased
> self.fill = fill
>
>
> p = Patch()
> p.facecolor = '#bfbf00'
> p.edgecolor = 'gold'
> p.facecolor = (1,.5,.5,.25)
> p.facecolor = 0.25
> p.fill = 'f'
> print 'p.facecolor', type(p.facecolor), p.facecolor
> print 'p.fill', type(p.fill), p.fill
> if p.fill_: print 'fill'
> else: print 'no fill'
> if doprint:
> print
> print 'Patch'
> p.print_traits()
>
>
>
> JDH
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys - and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
From: John H. <jdh...@ac...> - 2006年12月06日 16:10:08
>>>>> "Pellegrini" == Pellegrini Eric <eri...@ya...> writes:
 Pellegrini> Hi everybody, I would like to build an application
 Pellegrini> where many filled polygons will have to be displayed
 Pellegrini> on the screen. To do so, I would like to use
 Pellegrini> matplotlib but, up to now, my application is not fast
 Pellegrini> enough.
Hmm, I'm not seeing the performance problem on my system -- I can
create and save the figure in a fraction of a second. Is your numerix
setting set to numpy? Run the script with --verbose-helpful and send
us the output.
A few things to note: if you really want regular polygons, eg the
squared in your example, do any of the plot markers work for you.
plot(x, marker='s')
will be about as fast as mpl gets. You can set the marker size with
the markersize property.
Second, if you need arbitrary polygons, and need a lot of them, a
polygon collection will be faster. I had to bump the number of polys
up to about 8000 to show a dramatic performance difference.
Here are two scripts and performance numbers -- one using fill and one
using a polygon collection
> time python test.py -dAgg
6.595u 0.089s 0:06.68 99.8% 0+0k 0+0io 0pf+0w
> time python test2.py -dAgg
0.565u 0.033s 0:00.59 100.0% 0+0k 0+0io 0pf+0w
> cat test.py
import pylab
x = range(0,81000,10)
pylab.axis('off')
for i in range(0,len(x)-1):
 pylab.fill([x[i],x[i+1],x[i+1],x[i]],[10,10,20,20])
pylab.axis((0,max(x),0,610))
pylab.savefig('test')
pylab.show()
> cat test2.py
import pylab
from matplotlib.collections import PolyCollection
fig = pylab.figure()
ax = fig.add_subplot(111)
x = range(0,81000,10)
pylab.axis('off')
verts = [((x[i], 10), (x[i+1], 10), (x[i+1], 20), (x[i], 20)) for i in range(len(x)-1)]
col = PolyCollection(verts)
ax.add_collection(col)
pylab.axis((0,max(x),0,610))
pylab.savefig('test')
pylab.show()
From: Pellegrini E. <eri...@ya...> - 2006年12月06日 08:32:22
Hi everybody,
I would like to build an application where many filled polygons will have to be displayed on the screen. To do so, I would like to use matplotlib but, up to now, my application is not fast enough.
I use:
python 2.4.1
matplot-0.87.6
numpy-1.0rc1
and I checked my matplotlibrc file, the interactive flag is False.
Here is a little script that illustrates my problem. It takes something like 5-10s to display 80 polygons on the screen using a brand new machine.
###########################################
import pylab
x = range(0,810,10)
pylab.axis('off')
for i in range(0,len(x)-1):
 pylab.fill([x[i],x[i+1],x[i+1],x[i]],[10,10,20,20])
pylab.axis((0,810,0,610))
########################################
would you have any idea of what is going on or of a better way to implement this ?
Thank you very much
Eric
 		
---------------------------------
 Découvrez une nouvelle façon d'obtenir des réponses à toutes vos questions ! Profitez des connaissances, des opinions et des expériences des internautes sur Yahoo! Questions/Réponses.

Showing 4 results of 4

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