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

<< < 1 .. 7 8 9 10 11 .. 14 > >> (Page 9 of 14)
From: Simson G. <si...@ac...> - 2006年12月16日 02:07:31
Hm. thanks for the info. But it's not perfect... I get times in my 
formats, but not the dates. Here is the sample code:
#!/usr/bin/python
#
# Example boxplot code
#
from pylab import *
from matplotlib.dates import MonthLocator, WeekdayLocator, DateFormatter
from matplotlib.dates import MONDAY,SATURDAY
# fake up some data
set1 = (rand(50)+1) * 100
set2 = (rand(50)+2) * 100
boxplot(set1,positions=[732659])
boxplot(set2,positions=[732660])
ax = gca()
ax.xaxis.set_major_locator(MonthLocator())
ax.xaxis.set_major_formatter(DateFormatter('%D'))
ax.xaxis.set_minor_locator(WeekdayLocator(MONDAY))
ax.yaxis.set_major_formatter(FormatStrFormatter('%3.0f KB/s'))
ax.xaxis_date(None)
setp(ax.get_xticklabels(),'rotation',90,fontsize=8)
show()
==================
And yes, thanks for telling me about the timezone problem. I have 
been doing all of my work in GMT, only to be confounded.
We really need a manual that explains all of the axis stuff.
Now, how do I get two boxplots on the same plot?
(This would be SO MUCH EASIER if boxplot would take a list of objects 
that listed where the various thingies when...)
On Dec 15, 2006, at 8:56 PM, Pierre GM wrote:
>
>> 	2. I need to have the X axis of the boxplot be dates. There doesn't
>> seem to be an easy way to do that.
>
> Use the "position" keyword, as a list of date ordinals (output of 
> date2num).
> Then, use
> gca().xaxis_date(tz)
> where tz is your current timezone (you can use None, that's easier).
> Et voila.
> You probably gonna have to play with tick rotation and date 
> formatting, but
> that's another story
>
> Using the boxplot_demo
> #...
> # multiple box plots on one figure
> figure()
> positions = [732659, 732660]
> boxplot(data, positions=positions)
> gca().xaxis_date(None)
>
From: Pierre GM <pgm...@gm...> - 2006年12月16日 01:56:42
> 	2. I need to have the X axis of the boxplot be dates. There doesn't
> seem to be an easy way to do that.
Use the "position" keyword, as a list of date ordinals (output of date2num). 
Then, use
gca().xaxis_date(tz)
where tz is your current timezone (you can use None, that's easier).
Et voila.
You probably gonna have to play with tick rotation and date formatting, but 
that's another story
Using the boxplot_demo
#...
# multiple box plots on one figure
figure()
positions = [732659, 732660]
boxplot(data, positions=positions)
gca().xaxis_date(None)
From: Simson G. <si...@ac...> - 2006年12月16日 01:34:50
I've discovered that matplotlib does boxplots, and apparently this is 
what I should be using for one of the big graphs in my paper.
Two problems:
	1. I need to put 45 boxplots on a single date plot. Each of the 
boxes has a different amount of data that goes in it. Since the 
boxplot() function wants to calculate its own means, rather than have 
me provide them, I need to either create a single 45xN Numeric array 
(and I can't), or else I need to call it 45 times. But each time I 
call it, the last box obscures the previous one. That is, this code 
only shows one box:
===================
#!/usr/bin/python
from pylab import *
# fake up some data
set1 = (rand(50)+1) * 100
set2 = (rand(50)+2) * 100
boxplot(set1,positions=[1])
boxplot(set2,positions=[2])
show()
=================
The boxplot function returns a list of lines that it adds, but when 
I capture the lines from set1 and add them manually to the axes 
object, it fails. What should I do?
	2. I need to have the X axis of the boxplot be dates. There doesn't 
seem to be an easy way to do that.
Suggestions?
Thanks!
From: Simson G. <si...@ac...> - 2006年12月15日 23:56:18
Looks like I need to read *all* of the docstrings. I wish there was 
an easy way to search them....
On Dec 15, 2006, at 2:49 AM, Eric Firing wrote:
> Simson Garfinkel wrote:
>> HI. I wand to have just horizontal grid lines. Is there any way to 
>> do this? Thanks!
>
> gca().yaxis.grid(True)
> gca().xaxis.grid(False)
>
> Here is the grid method docstring:
>
> def grid(self, b=None, which='major', **kwargs):
> """
> Set the axis grid on or off; b is a boolean use which =
> 'major' | 'minor' to set the grid for major or minor ticks
>
> if b is None and len(kwargs)==0, toggle the grid state. If
> kwargs are supplied, it is assumed you want the grid on and b
> will be set to True
>
> kwargs are used to set the line properties of the grids, eg,
>
> xax.grid(color='r', linestyle='-', linewidth=2)
>
>
> Eric
>
From: Eric F. <ef...@ha...> - 2006年12月15日 07:50:03
Simson Garfinkel wrote:
> HI. I wand to have just horizontal grid lines. Is there any way to do 
> this? Thanks!
gca().yaxis.grid(True)
gca().xaxis.grid(False)
Here is the grid method docstring:
 def grid(self, b=None, which='major', **kwargs):
 """
 Set the axis grid on or off; b is a boolean use which =
 'major' | 'minor' to set the grid for major or minor ticks
 if b is None and len(kwargs)==0, toggle the grid state. If
 kwargs are supplied, it is assumed you want the grid on and b
 will be set to True
 kwargs are used to set the line properties of the grids, eg,
 xax.grid(color='r', linestyle='-', linewidth=2)
Eric
From: Simson G. <si...@ac...> - 2006年12月15日 03:37:07
HI. I wand to have just horizontal grid lines. Is there any way to do 
this? Thanks!
From: Eric F. <ef...@ha...> - 2006年12月15日 03:20:35
I don't recognize the error output at all, but it looks like you have an 
old version. The current release is 0.87.7. I don't know of any 
released version in which contour_demo.py did not run at all, though.
The X errors make me wonder whether you are trying to run from inside an 
IDE.
My suggestion would be to delete the installation you have, do a fresh 
install of the current version, and then try running demos on the 
command line, making sure the demos are from the newly installed version.
If you still have a problem, tell us what version you are running, how 
it was installed, and on what kind of system.
Eric
Mohammad Hammoudeh wrote:
> Hi everybody,
> I'm trying to run contour_demo.pp example but I'm having this error. 
> Anybody can help?
> 
> Thanks,
> 
> X Error: BadDevice, invalid or uninitialized input device 166
> Major opcode: 144
> Minor opcode: 3
> Resource id: 0x0
> Failed to open device
> X Error: BadDevice, invalid or uninitialized input device 166
> Major opcode: 144
> Minor opcode: 3
> Resource id: 0x0
> Failed to open device
> [-0.8666166 ,-0.49865195,-0.13068729, 0.23727736, 0.60524202, 0.97320667,
> 1.34117133,]
> type: <type 'array'>
> ['__copy__', '__deepcopy__', 'astype', 'byteswapped', 'copy', 
> 'iscontiguous', 'itemsize', 'resize', 'savespace', 'spacesaver', 'tolist', 
> 'toscalar', 'tostring', 'typecode']
> * * * * * * * * * *
> <a list of 7 LineCollection objects>
> type: <class 'matplotlib.cbook.silent_list'>
> ['__add__', '__class__', '__contains__', '__delattr__', '__delitem__', 
> '__delslice__', '__dict__', '__doc__', '__eq__', '__ge__', 
> '__getattribute__', '__getitem__', '__getslice__', '__gt__', '__hash__', 
> '__iadd__', '__imul__', '__init__', '__iter__', '__le__', '__len__', 
> '__lt__', '__module__', '__mul__', '__ne__', '__new__', '__reduce__', 
> '__reduce_ex__', '__repr__', '__reversed__', '__rmul__', '__setattr__', 
> '__setitem__', '__setslice__', '__str__', '__weakref__', 'append', 'count', 
> 'extend', 'index', 'insert', 'mappable', 'pop', 'remove', 'reverse', 'sort', 
> 'type']
> * * * * * * * * * *
> Traceback (most recent call last):
> File "./contour_demo.py", line 30, in ?
> clabel(CS, inline=1, fontsize=10)
> File "/usr/lib/python2.4/site-packages/matplotlib/pylab.py", line 1731, in 
> clabel
> ret = gca().clabel(*args, **kwargs)
> File "/usr/lib/python2.4/site-packages/matplotlib/axes.py", line 1241, in 
> clabel
> return self._contourLabeler.clabel(*args, **kwargs)
> File "/usr/lib/python2.4/site-packages/matplotlib/contour.py", line 150, 
> in clabel
> levels = [con._label for con in contours]
> AttributeError: _label
> 
> 
> 
> X Error: BadDevice, invalid or uninitialized input device 166
> Major opcode: 144
> Minor opcode: 3
> Resource id: 0x0
> Failed to open device
> X Error: BadDevice, invalid or uninitialized input device 166
> Major opcode: 144
> Minor opcode: 3
> Resource id: 0x0
> Failed to open device
> [-0.8666166 ,-0.49865195,-0.13068729, 0.23727736, 0.60524202, 0.97320667,
> 1.34117133,]
> type: <type 'array'>
> ['__copy__', '__deepcopy__', 'astype', 'byteswapped', 'copy', 
> 'iscontiguous', 'itemsize', 'resize', 'savespace', 'spacesaver', 'tolist', 
> 'toscalar', 'tostring', 'typecode']
> * * * * * * * * * *
> <a list of 7 LineCollection objects>
> type: <class 'matplotlib.cbook.silent_list'>
> ['__add__', '__class__', '__contains__', '__delattr__', '__delitem__', 
> '__delslice__', '__dict__', '__doc__', '__eq__', '__ge__', 
> '__getattribute__', '__getitem__', '__getslice__', '__gt__', '__hash__', 
> '__iadd__', '__imul__', '__init__', '__iter__', '__le__', '__len__', 
> '__lt__', '__module__', '__mul__', '__ne__', '__new__', '__reduce__', 
> '__reduce_ex__', '__repr__', '__reversed__', '__rmul__', '__setattr__', 
> '__setitem__', '__setslice__', '__str__', '__weakref__', 'append', 'count', 
> 'extend', 'index', 'insert', 'mappable', 'pop', 'remove', 'reverse', 'sort', 
> 'type']
> * * * * * * * * * *
> Traceback (most recent call last):
> File "./contour_demo.py", line 30, in ?
> clabel(CS, inline=1, fontsize=10)
> File "/usr/lib/python2.4/site-packages/matplotlib/pylab.py", line 1731, in 
> clabel
> ret = gca().clabel(*args, **kwargs)
> File "/usr/lib/python2.4/site-packages/matplotlib/axes.py", line 1241, in 
> clabel
> return self._contourLabeler.clabel(*args, **kwargs)
> File "/usr/lib/python2.4/site-packages/matplotlib/contour.py", line 150, 
> in clabel
> levels = [con._label for con in contours]
> AttributeError: _label
> 
> _________________________________________________________________
> It's Hotmail's 10th Birthday! Come and play Pass the Parcel 
> http://www.msnpasstheparcel.com
> 
> 
> -------------------------------------------------------------------------
> 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: Simson G. <si...@ac...> - 2006年12月14日 20:09:08
Greetings. I've been having lots of luck with my date plots. But 
I've been having a problem getting the dateformatter to work. I'm 
using the code below. The dates keep getting formatted with the 
default, "Sep 28 2006" instead of what I want, "Sep 28"
Any thoughts?
from datetime import date,timedelta
from matplotlib.dates import MonthLocator, WeekdayLocator, 
DateFormatter,MONDAY,SATURDAY
from pylab import *
def dateplot():
 dates = drange(date(2006,10,1),date(2006,12,1),timedelta(days=1))
 vals = 500*(randn(len(dates))+2)
 figure(num=1, figsize=(6.5,4))
 axes([.15,.3,.8,.5])
 ax = gca() # get the current graphics 
region
 title(r"Average daily bandwidth")
 ax.xaxis.set_major_formatter(DateFormatter('%b %d'))
 ax.yaxis.set_major_formatter(FormatStrFormatter('%3.0f KBps'))
 plot_date(dates, vals, 'bo')
 # Rotate the labels
 labels = ax.get_xticklabels()
 setp(labels,'rotation',90,fontsize=8)
 grid(True)
 savefig("x.pdf",format='pdf')
if(__name__=='__main__'):
 dateplot()
From: Simson G. <si...@ac...> - 2006年12月14日 19:28:37
I've been able to figure out how to easily do error bars on a plot_date.
Here is how I do it:
The variables coming in are "dates" which is an array of my dates (in 
days since 0001年01月01日), averages, p10 (which is the bottom of my 
error bars), and p90 (which is the top of my error bars)
 plot_date(dates, averages, 'bo')
 # Draw the tops of the error bars
 ax.vlines(dates,averages,p90)
 ax.hlines(p90,dates-.25,dates+.25)
 # Draw the bottom part of the error bars
 ax.vlines(dates,averages,p10)
 ax.hlines(p10,dates-.25,dates+.25)
It's pretty sweet.
I'm having other problems which I will post separately, but this is 
working well.
On Dec 3, 2006, at 12:02 PM, Pierre GM wrote:
> On Saturday 02 December 2006 17:39, Simson Garfinkel wrote:
>> Hi. I'm interested in creating a date plot showing bandwidth along a
>> link. I want to have a dot in the center of each date with the
>> average bandwidth and use the error bars to show the 25th and 75th
>> percentiles. I've been trying to figure out how to do this and am
>> having problems.
>
> My 2c:
> Don't bother yet about dates: first get the plot as you want it, 
> assuming that
> your x data are floats (use date2num if needed). Then you can 
> tackle the
> problem of displaying dates.
>
> If you poke around the sources (axes.py). you'll find that 
> 'plot_date' is only
> 'plot', where a couple of extra parameters are set:
> if xdate:
> self.xaxis_date(tz)
> 'xdate' is a flag indicating whether the data on the x axis are 
> dates (True)
> or not (False), 'tz' is the timezone flag (default to None), and 
> 'self' is
> your current axes object (you can get its handle by gca() if you 
> haven't
> specified it otherwise).
>
> Combining these pieces of information should to the trick (or most 
> of it).
> Let us know how it goes anyway.
> P.
>
From: Eric F. <ef...@ha...> - 2006年12月14日 18:14:49
David,
I have made some changes in svn that address all but one of the points 
you made:
[....]
> if self.clip:
> mask = ma.getmaskorNone(val)
> if mask == None:
> val = ma.array(clip(val.filled(vmax), vmin, vmax))
> else:
> val = ma.array(clip(val.filled(vmax), vmin, vmax),
> mask=mask)
The real problem here is that I should not have been using 
getmaskorNone(). In numpy.ma, we need nomask, not None, so we want an 
ordinary getmask() call. ma.array(...., mask=ma.nomask) is very fast, 
so the problem goes away.
> 
> Actually, the problem is in ma.array: with a value of mask to None, it 
> should not make a difference between mask = None or no mask arg, right ? 
But it does, because for numpy it needs to be nomask; it does something 
with None, but whatever it is, it is very slow.
> I didn't change ma.array to keep my change as local as possible. To 
> change only this operation as above gives a speed up from 1.8 s to ~ 1.0 
> s for to_rgba, which means calling show goes from ~ 2.2 s to ~1.4 s. I 
> also changed 
> result = (val-vmin)/float(vmax-vmin)
> 
> to
> 
> invcache = 1.0 / (vmax - vmin)
> result = (val-vmin) * invcache
This is the one I did not address. I don't understand how this could be 
making much difference, and some testing using ipython and %prun with 
1-line operations showed little difference with variations on this 
theme. The fastest would appear to be (and logically should be, I 
think) result = (val-vmin)*(1.0/(vmax-vmin)), but I don't think it makes 
much difference--it looks to me like maybe 10-20 msec, not 100, on my 
Pentium M 1.6 Ghz. Maybe still worthwhile, so I may yet make the change 
after more careful testing.
> 
> which gives a moderate speed up (around 100 ms for a 8000x256 points 
> array). Once you make both those changes, the clip call is by far the 
> most expensive operation in normalize functor, but the functor is not 
> really expensive anymore compared to the rest, so this is not where I 
> looked at.
> 
> For the where calls in Colormap functor, I was wondering if they are 
> necessary in all cases: some of those calls seem redundant, and it may 
> be possible to detect that before calling them. This should be both 
> easier and faster, at least in this case, than having a fast where ?
> 
You hit the nail squarely: where() is the wrong function to use, and I 
have eliminated it from colors.py. The much faster replacement is 
putmask, which does as well as direct indexing with a Boolean but works 
with all three numerical packages. I think that using the fast putmask 
is better than trying to figure out special cases in which there would 
be nothing to put, although I could be convinced otherwise.
> I understand that support of multiple array backend, support of mask 
> arrays have cost consequences. But it looks like it may be possible to 
> speed things up for cases where an array has only meaningful values/no 
> mask.
The big gains here were essentially bug fixes--picking the appropriate 
function (getmask versus getmaskorNone and putmask versus where).
Here is the colors.py diff:
--- trunk/matplotlib/lib/matplotlib/colors.py	2006年12月03日 21:54:38	2906
+++ trunk/matplotlib/lib/matplotlib/colors.py	2006年12月14日 08:27:04	2923
@@ -30,9 +30,9 @@
 """
 import re
-from numerix import array, arange, take, put, Float, Int, where, \
+from numerix import array, arange, take, put, Float, Int, putmask, \
 zeros, asarray, sort, searchsorted, sometrue, ravel, divide,\
- ones, typecode, typecodes, alltrue
+ ones, typecode, typecodes, alltrue, clip
 from numerix.mlab import amin, amax
 import numerix.ma as ma
 import numerix as nx
@@ -536,8 +536,9 @@
 lut[0] = y1[0]
 lut[-1] = y0[-1]
 # ensure that the lut is confined to values between 0 and 1 by 
clipping it
- lut = where(lut > 1., 1., lut)
- lut = where(lut < 0., 0., lut)
+ clip(lut, 0.0, 1.0)
+ #lut = where(lut > 1., 1., lut)
+ #lut = where(lut < 0., 0., lut)
 return lut
@@ -588,16 +589,16 @@
 vtype = 'array'
 xma = ma.asarray(X)
 xa = xma.filled(0)
- mask_bad = ma.getmaskorNone(xma)
+ mask_bad = ma.getmask(xma)
 if typecode(xa) in typecodes['Float']:
- xa = where(xa == 1.0, 0.9999999, xa) # Tweak so 1.0 is in 
range.
+ putmask(xa, xa==1.0, 0.9999999) #Treat 1.0 as slightly less 
than 1.
 xa = (xa * self.N).astype(Int)
- mask_under = xa < 0
- mask_over = xa > self.N-1
- xa = where(mask_under, self._i_under, xa)
- xa = where(mask_over, self._i_over, xa)
- if mask_bad is not None: # and sometrue(mask_bad):
- xa = where(mask_bad, self._i_bad, xa)
+ # Set the over-range indices before the under-range;
+ # otherwise the under-range values get converted to over-range.
+ putmask(xa, xa>self.N-1, self._i_over)
+ putmask(xa, xa<0, self._i_under)
+ if mask_bad is not None and mask_bad.shape == xa.shape:
+ putmask(xa, mask_bad, self._i_bad)
 rgba = take(self._lut, xa)
 if vtype == 'scalar':
 rgba = tuple(rgba[0,:])
@@ -752,7 +753,7 @@
 return 0.*value
 else:
 if clip:
- mask = ma.getmaskorNone(val)
+ mask = ma.getmask(val)
 val = ma.array(nx.clip(val.filled(vmax), vmin, vmax),
 mask=mask)
 result = (val-vmin)/float(vmax-vmin)
@@ -804,7 +805,7 @@
 return 0.*value
 else:
 if clip:
- mask = ma.getmaskorNone(val)
+ mask = ma.getmask(val)
 val = ma.array(nx.clip(val.filled(vmax), vmin, vmax),
 mask=mask)
 result = 
(ma.log(val)-nx.log(vmin))/(nx.log(vmax)-nx.log(vmin))
Eric
From: Abhijit C. <ce...@gm...> - 2006年12月14日 18:13:13
I am getting this weird message. This is a linux machine. the matplotlib
version 0.87.7
>>> from pylab import *
Traceback (most recent call last):
 File "<stdin>", line 1, in ?
 File "/foo/python/site-packages/lib/python/pylab.py", line 1, in ?
 from matplotlib.pylab import *
 File "/foo/python/site-packages/lib/python/matplotlib/pylab.py", line 201,
in ?
 from axes import Axes, PolarAxes
 File "/foo/python/site-packages/lib/python/matplotlib/axes.py", line 15,
in ?
 from axis import XAxis, YAxis
 File "/foo/python/site-packages/lib/python/matplotlib/axis.py", line 16,
in ?
 from lines import Line2D, TICKLEFT, TICKRIGHT, TICKUP, TICKDOWN
 File "/foo/python/site-packages/lib/python/matplotlib/lines.py", line 11,
in ?
 import matplotlib.agg as agg
 File "/foo/python/site-packages/lib/python/matplotlib/agg.py", line 106,
in ?
 pi = cvar.pi
AttributeError: 'swigvarlink' object has no attribute 'pi'
>>>
From: Eric F. <ef...@ha...> - 2006年12月14日 17:35:53
You need to update your mpl to the current release or svn. This was 
fixed quite a few months ago, but I don't remember exactly when.
Eric
Brian Blais wrote:
> Hello,
> 
> If I do the following:
> 
> plot([1],[1],'o')
> 
> it plots the one dot correctly.
> 
> if, however, one of those numbers is zero:
> 
> 
> plot([1],[0],'o')
> 
> I get a floating point/divide by zero error:
> 
> 
> /usr/lib/python2.4/site-packages/matplotlib/ticker.py in scale_range(vmin, vmax, n, 
> threshold)
> 731 dv = abs(vmax - vmin)
> 732 meanv = 0.5*(vmax+vmin)
> --> 733 var = dv/max(abs(vmin), abs(vmax))
> 734 if var < 1e-12:
> 735 return 1.0, 0.0
> 
> ZeroDivisionError: float division
> 
> 
> Is there a fix for this?
> 
> 
> In [11]:matplotlib.__version__
> Out[11]:'0.87.2'
> 
> 
> running linux, python 2.4.
> 
> 
> 
> 
> 			thanks,
> 
> 
> 				Brian Blais
> 
> 
From: Steve S. <el...@gm...> - 2006年12月14日 16:53:37
Brian Blais wrote:
> 
> plot([1],[0],'o')
> 
> I get a floating point/divide by zero error:
> 
> 
> /usr/lib/python2.4/site-packages/matplotlib/ticker.py in scale_range(vmin, vmax, n, 
> threshold)
> 731 dv = abs(vmax - vmin)
> 732 meanv = 0.5*(vmax+vmin)
> --> 733 var = dv/max(abs(vmin), abs(vmax))
> 734 if var < 1e-12:
> 735 return 1.0, 0.0
> 
> ZeroDivisionError: float division
> 
> 
> Is there a fix for this?
> 
You have to upgrade.
In [39]: plot([1],[0],'o')
Out[39]: [<matplotlib.lines.Line2D instance at 0xa38ac80c>]
In [40]: matplotlib.__version__
Out[40]: '0.87.7'
In [41]: matplotlib.__revision__
Out[41]: '$Revision: 2835 $'
-- 
cheers,
steve
Random number generation is the art of producing pure gibberish as 
quickly as possible.
From: Brian B. <bb...@br...> - 2006年12月14日 16:43:41
Hello,
If I do the following:
plot([1],[1],'o')
it plots the one dot correctly.
if, however, one of those numbers is zero:
plot([1],[0],'o')
I get a floating point/divide by zero error:
/usr/lib/python2.4/site-packages/matplotlib/ticker.py in scale_range(vmin, vmax, n, 
threshold)
 731 dv = abs(vmax - vmin)
 732 meanv = 0.5*(vmax+vmin)
--> 733 var = dv/max(abs(vmin), abs(vmax))
 734 if var < 1e-12:
 735 return 1.0, 0.0
ZeroDivisionError: float division
Is there a fix for this?
In [11]:matplotlib.__version__
Out[11]:'0.87.2'
running linux, python 2.4.
			thanks,
				Brian Blais
-- 
-----------------
 bb...@br...
 http://web.bryant.edu/~bblais
From: Mohammad H. <pow...@ho...> - 2006年12月14日 15:12:21
Hi everybody,
I'm trying to run contour_demo.pp example but I'm having this error. 
Anybody can help?
Thanks,
X Error: BadDevice, invalid or uninitialized input device 166
 Major opcode: 144
 Minor opcode: 3
 Resource id: 0x0
Failed to open device
X Error: BadDevice, invalid or uninitialized input device 166
 Major opcode: 144
 Minor opcode: 3
 Resource id: 0x0
Failed to open device
[-0.8666166 ,-0.49865195,-0.13068729, 0.23727736, 0.60524202, 0.97320667,
 1.34117133,]
type: <type 'array'>
['__copy__', '__deepcopy__', 'astype', 'byteswapped', 'copy', 
'iscontiguous', 'itemsize', 'resize', 'savespace', 'spacesaver', 'tolist', 
'toscalar', 'tostring', 'typecode']
* * * * * * * * * *
<a list of 7 LineCollection objects>
type: <class 'matplotlib.cbook.silent_list'>
['__add__', '__class__', '__contains__', '__delattr__', '__delitem__', 
'__delslice__', '__dict__', '__doc__', '__eq__', '__ge__', 
'__getattribute__', '__getitem__', '__getslice__', '__gt__', '__hash__', 
'__iadd__', '__imul__', '__init__', '__iter__', '__le__', '__len__', 
'__lt__', '__module__', '__mul__', '__ne__', '__new__', '__reduce__', 
'__reduce_ex__', '__repr__', '__reversed__', '__rmul__', '__setattr__', 
'__setitem__', '__setslice__', '__str__', '__weakref__', 'append', 'count', 
'extend', 'index', 'insert', 'mappable', 'pop', 'remove', 'reverse', 'sort', 
'type']
* * * * * * * * * *
Traceback (most recent call last):
 File "./contour_demo.py", line 30, in ?
 clabel(CS, inline=1, fontsize=10)
 File "/usr/lib/python2.4/site-packages/matplotlib/pylab.py", line 1731, in 
clabel
 ret = gca().clabel(*args, **kwargs)
 File "/usr/lib/python2.4/site-packages/matplotlib/axes.py", line 1241, in 
clabel
 return self._contourLabeler.clabel(*args, **kwargs)
 File "/usr/lib/python2.4/site-packages/matplotlib/contour.py", line 150, 
in clabel
 levels = [con._label for con in contours]
AttributeError: _label
X Error: BadDevice, invalid or uninitialized input device 166
 Major opcode: 144
 Minor opcode: 3
 Resource id: 0x0
Failed to open device
X Error: BadDevice, invalid or uninitialized input device 166
 Major opcode: 144
 Minor opcode: 3
 Resource id: 0x0
Failed to open device
[-0.8666166 ,-0.49865195,-0.13068729, 0.23727736, 0.60524202, 0.97320667,
 1.34117133,]
type: <type 'array'>
['__copy__', '__deepcopy__', 'astype', 'byteswapped', 'copy', 
'iscontiguous', 'itemsize', 'resize', 'savespace', 'spacesaver', 'tolist', 
'toscalar', 'tostring', 'typecode']
* * * * * * * * * *
<a list of 7 LineCollection objects>
type: <class 'matplotlib.cbook.silent_list'>
['__add__', '__class__', '__contains__', '__delattr__', '__delitem__', 
'__delslice__', '__dict__', '__doc__', '__eq__', '__ge__', 
'__getattribute__', '__getitem__', '__getslice__', '__gt__', '__hash__', 
'__iadd__', '__imul__', '__init__', '__iter__', '__le__', '__len__', 
'__lt__', '__module__', '__mul__', '__ne__', '__new__', '__reduce__', 
'__reduce_ex__', '__repr__', '__reversed__', '__rmul__', '__setattr__', 
'__setitem__', '__setslice__', '__str__', '__weakref__', 'append', 'count', 
'extend', 'index', 'insert', 'mappable', 'pop', 'remove', 'reverse', 'sort', 
'type']
* * * * * * * * * *
Traceback (most recent call last):
 File "./contour_demo.py", line 30, in ?
 clabel(CS, inline=1, fontsize=10)
 File "/usr/lib/python2.4/site-packages/matplotlib/pylab.py", line 1731, in 
clabel
 ret = gca().clabel(*args, **kwargs)
 File "/usr/lib/python2.4/site-packages/matplotlib/axes.py", line 1241, in 
clabel
 return self._contourLabeler.clabel(*args, **kwargs)
 File "/usr/lib/python2.4/site-packages/matplotlib/contour.py", line 150, 
in clabel
 levels = [con._label for con in contours]
AttributeError: _label
_________________________________________________________________
It's Hotmail's 10th Birthday! Come and play Pass the Parcel 
http://www.msnpasstheparcel.com
From: David C. <da...@ar...> - 2006年12月14日 03:09:35
Eric Firing wrote:
>
> Regarding the clip line, I think that your test for mask is None is 
> not the right solution because it knocks out the clipping operation, 
> but the clipping is intended regardless of the state of the mask. I 
> had expected it to be a very fast operation, so I am surprised it is a 
> bottleneck; in any case I can take a look to see how it can be sped 
> up, or whether it can be bypassed in some cases. Maybe it is also 
> using "where" internally.
(again, sorry for the double posting, I always forget that some ML do 
not reply automatically to the ML)
My wordings were vague at best :) The clipping operation is *not* 
removed, and it was not the culprit (it becomes a bottleneck once you 
get the 4x speed issue, though). What I did was:
if self.clip:
 mask = ma.getmaskorNone(val)
 if mask == None:
 val = ma.array(clip(val.filled(vmax), vmin, vmax))
 else:
 val = ma.array(clip(val.filled(vmax), vmin, vmax),
 mask=mask)
Actually, the problem is in ma.array: with a value of mask to None, it 
should not make a difference between mask = None or no mask arg, right ? 
I didn't change ma.array to keep my change as local as possible. To 
change only this operation as above gives a speed up from 1.8 s to ~ 1.0 
s for to_rgba, which means calling show goes from ~ 2.2 s to ~1.4 s. I 
also changed
 
result = (val-vmin)/float(vmax-vmin)
to
invcache = 1.0 / (vmax - vmin)
result = (val-vmin) * invcache
which gives a moderate speed up (around 100 ms for a 8000x256 points 
array, still in the 5-10 % range of the whole cost, though, and is not 
likely to cause any hidden bug). Once you make both those changes, the 
clip call is by far the most expensive operation in normalize functor, 
but the functor is not really expensive anymore compared to the rest, so 
this is not where I looked at after.
For the where calls in Colormap functor, I was wondering if they are 
necessary in all cases: some of those calls seem redundant, and it may 
be possible to detect that before calling them. This should be both 
easier and faster, at least in this case, than having a fast where ?
I understand that support of multiple array backend, support of mask 
arrays have cost consequences. But it looks like it may be possible to 
speed things up for cases where an array has only meaningful values/no 
mask.
cheers,
David
From: Eric F. <ef...@ha...> - 2006年12月14日 00:46:22
It's fixed now.
Eric
Rob Hetland wrote:
> fill(x, y) returns an error like:
[....]
> /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site- 
> packages/matplotlib/axes.py in update_datalim(self, xys)
> 966 # and the data in xydata
> 967 xys = asarray(xys)
> --> 968 self.dataLim.update_numerix_xy(xys, -1)
> 969
> 970
> 
> <type 'exceptions.TypeError'>: Bbox::update_numerix_xy expected 
> numerix array
From: Eric F. <ef...@ha...> - 2006年12月14日 00:12:19
Rob,
OK, thanks. That sounds like something resulting from the change I made 
to support 2D array input to plot. I will check it.
Eric
Rob Hetland wrote:
> fill(x, y) returns an error like:
> 
> 
> /Users/rob/Projects/Merrimack/Grid/landfill.py in <module>()
> 24 for filename in filenames:
> 25 x, y, = pl.load(filename).T
> ---> 26 pl.fill(x, y, facecolor=fillcolor, alpha=fillalpha)
> 27
> 28
> 
> /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site- 
> packages/matplotlib/pylab.py in fill(*args, **kwargs)
> 1869 hold(h)
> 1870 try:
> -> 1871 ret = gca().fill(*args, **kwargs)
> 1872 draw_if_interactive()
> 1873 except:
> 
> /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site- 
> packages/matplotlib/axes.py in fill(self, *args, **kwargs)
> 3677 patches = []
> 3678 for poly in self._get_patches_for_fill(*args, 
> **kwargs):
> -> 3679 self.add_patch( poly )
> 3680 patches.append( poly )
> 3681 self.autoscale_view()
> 
> /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site- 
> packages/matplotlib/axes.py in add_patch(self, p)
> 951 xys = self._get_verts_in_data_coords(
> 952 p.get_transform(), p.get_verts())
> --> 953 self.update_datalim(xys)
> 954 self.patches.append(p)
> 955
> 
> /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site- 
> packages/matplotlib/axes.py in update_datalim(self, xys)
> 966 # and the data in xydata
> 967 xys = asarray(xys)
> --> 968 self.dataLim.update_numerix_xy(xys, -1)
> 969
> 970
> 
> <type 'exceptions.TypeError'>: Bbox::update_numerix_xy expected 
> numerix array
> WARNING: Failure executing file: <landfill.py>
> 
> 
> ----
> Rob Hetland, Associate Professor
> Dept. of Oceanography, Texas A&M University
> http://pong.tamu.edu/~rob
> phone: 979-458-0096, fax: 979-845-6331
> 
> 
> 
> -------------------------------------------------------------------------
> 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: Rob H. <he...@ta...> - 2006年12月13日 23:49:09
fill(x, y) returns an error like:
/Users/rob/Projects/Merrimack/Grid/landfill.py in <module>()
 24 for filename in filenames:
 25 x, y, = pl.load(filename).T
---> 26 pl.fill(x, y, facecolor=fillcolor, alpha=fillalpha)
 27
 28
/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site- 
packages/matplotlib/pylab.py in fill(*args, **kwargs)
 1869 hold(h)
 1870 try:
-> 1871 ret = gca().fill(*args, **kwargs)
 1872 draw_if_interactive()
 1873 except:
/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site- 
packages/matplotlib/axes.py in fill(self, *args, **kwargs)
 3677 patches = []
 3678 for poly in self._get_patches_for_fill(*args, 
**kwargs):
-> 3679 self.add_patch( poly )
 3680 patches.append( poly )
 3681 self.autoscale_view()
/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site- 
packages/matplotlib/axes.py in add_patch(self, p)
 951 xys = self._get_verts_in_data_coords(
 952 p.get_transform(), p.get_verts())
--> 953 self.update_datalim(xys)
 954 self.patches.append(p)
 955
/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site- 
packages/matplotlib/axes.py in update_datalim(self, xys)
 966 # and the data in xydata
 967 xys = asarray(xys)
--> 968 self.dataLim.update_numerix_xy(xys, -1)
 969
 970
<type 'exceptions.TypeError'>: Bbox::update_numerix_xy expected 
numerix array
WARNING: Failure executing file: <landfill.py>
----
Rob Hetland, Associate Professor
Dept. of Oceanography, Texas A&M University
http://pong.tamu.edu/~rob
phone: 979-458-0096, fax: 979-845-6331
From: Steve S. <el...@gm...> - 2006年12月13日 23:42:36
ch...@se... wrote:
> Thanks for help. Now it freezes always here...
> 
> 
> GTK requires pygtk
> GTKAgg requires pygtk
> TKAgg requires TkInter
I never used eggs, but I guess you need to install these libs by yourself.
apt-cache search for this stuff and make sure you install the *-dev 
versions of the packages.
Seems that you need (list may not exhaustive) python-gtk2-dev (pygtk) 
and tk8.4-dev, python-tk, ... (TkInter, this is a little tricky to 
search for, check the dependencies)
-- 
cheers,
steve
Random number generation is the art of producing pure gibberish as 
quickly as possible.
From: <ch...@se...> - 2006年12月13日 20:47:32
Thanks for help. Now it freezes always here...
GTK requires pygtk
GTKAgg requires pygtk
TKAgg requires TkInter
warning: no files found matching 'MANIFEST'
warning: no files found matching 'lib/matplotlib/toolkits'
no previously-included directories found matching 'examples/_tmp_*'
In file included from /usr/include/python2.4/Python.h:8,
 from CXX/Objects.hxx:9,
 from CXX/Extensions.hxx:19,
 from src/_transforms.h:12,
 from src/_ns_transforms.cpp:5:
/usr/include/python2.4/pyconfig.h:832:1: warning: "_POSIX_C_SOURCE" redefined
In file included from /usr/include/c++/3.3/i486-linux/bits/os_defines.h:39,
 from /usr/include/c++/3.3/i486-linux/bits/c++config.h:35,
 from /usr/include/c++/3.3/functional:53,
 from src/_ns_transforms.cpp:1:
/usr/include/features.h:131:1: warning: this is the location of the previous
definition
Chris
From: Christopher B. <Chr...@no...> - 2006年12月13日 19:54:41
Eric Firing wrote:
> Regarding the clip line, I think that your test for mask is None is not 
> the right solution because it knocks out the clipping operation, but the 
> clipping is intended regardless of the state of the mask. I had 
> expected it to be a very fast operation,
for what it's worth, a few years ago a wrote a "fast_clip" c extension 
that did clip without making nearly as many temporary arrays as the 
Numeric one -- I don't know what numpy does , I haven't needed a fast 
clip recently. I'd be glad to send the code to anyone interested.
> Now I recall very recent discussion explaining why "where" is slow 
> compared to indexing with a boolean, so I know I can speed it up with 
> numpy. Unfortunately Numeric does not support this, so maybe what will 
> be needed is numerix functions that take advantage of numpy when 
> available.
good idea.
> This is one of those times when I really wish we could drop 
> Numeric and numarray support *now* and start taking full advantage of numpy.
I'd love that too. Maybe your proposal is a good one, though -- make 
numeric functions that are optimized for numpy. I think that's a good 
way to transition.
-Chris
-- 
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chr...@no...
From: Simson G. <si...@ac...> - 2006年12月13日 19:18:01
Attachments: smime.p7s
When I look at http://matplotlib.sourceforge.net/tutorial.html with 
Safari, I see a lot of broken images. Any ideas?
From: Eric F. <ef...@ha...> - 2006年12月13日 18:30:01
David,
> - first, we can see that in expose_event (one is expensive, the other 
> negligeable, from my understanding), two calls are pretty expensive:
> the __call__ at line 735 (for normalize functor) and one for __call__ 
> at line 568 (for colormap functor).
> - for normalize functor, one line is expensive: val = 
> ma.array(clip(val.filled(vmax), vmin, vmax), mask=mask). If I put a test 
> on mask when mask is None (which it is in my case), then the function 
> becomes negligeable.
> - for colormap functor, the 3 where calls are expensive. I am not 
> sure to understand in which case they are useful; if I understand 
> correctly, one tries to avoid
> values out of range (0, N), and force out of range values to be clipped. 
> Isn't there an easier way than using where ?
> 
> If I remove the where in the colormap functor, I have a 4x speed 
> increase for the to_rgba function. After that, it becomes a bit more 
> tricky to change things for someone like me who have no knowledge about 
> matplotlib internals.
The things you have identified were added by me to support masked array 
bad values and special colors for regions above or below the mapped 
range of values. I will be happy to make changes to speed them up.
Regarding the clip line, I think that your test for mask is None is not 
the right solution because it knocks out the clipping operation, but the 
clipping is intended regardless of the state of the mask. I had 
expected it to be a very fast operation, so I am surprised it is a 
bottleneck; in any case I can take a look to see how it can be sped up, 
or whether it can be bypassed in some cases. Maybe it is also using 
"where" internally.
Now I recall very recent discussion explaining why "where" is slow 
compared to indexing with a boolean, so I know I can speed it up with 
numpy. Unfortunately Numeric does not support this, so maybe what will 
be needed is numerix functions that take advantage of numpy when 
available. This is one of those times when I really wish we could drop 
Numeric and numarray support *now* and start taking full advantage of numpy.
In any case, thanks for pointing out the slowdowns--I will fix them as 
best I can--and keep at it. I share your interest in speeding up 
interactive use of matplotlib, along with fixing bugs, filling holes in 
functionalisy, and smoothing rough edges. There is a lot to be done. As 
John noted, though, there will always be tradeoffs among flexibility, 
code simplicity, generality, and speed.
Eric
From: Werner F. B. <wer...@fr...> - 2006年12月13日 18:25:11
I have received reports from clients with the following traceback or 
similar.
This happens when application is packaged with py2exe.
Traceback (most recent call last):
 File "appwine.pyo", line 1341, in OnToolbarChart
 File "frameplotmpl.pyo", line 19, in ?
 File "matplotlib\backends\__init__.pyo", line 19, in ?
 File "matplotlib\backends\backend_wxagg.pyo", line 18, in ?
 File "matplotlib\backends\backend_agg.pyo", line 82, in ?
 File "matplotlib\figure.pyo", line 3, in ?
 File "matplotlib\axes.pyo", line 14, in ?
 File "matplotlib\axis.pyo", line 21, in ?
 File "matplotlib\font_manager.pyo", line 982, in ?
 File "matplotlib\font_manager.pyo", line 826, in __init__
 File "matplotlib\font_manager.pyo", line 819, in rebuild
 File "matplotlib\font_manager.pyo", line 454, in createFontDict
SystemError: error return without exception set
Any hints of what might cause this would be very welcome.
Werner
P.S.
I am still on matplotlib version '0.82' (plan to upgrade to newer 
version but need to upgrade to Unicode wxPython first), with Python 2.4 
and wxPython 2.6.x
6 messages has been excluded from this view by a project administrator.

Showing results of 339

<< < 1 .. 7 8 9 10 11 .. 14 > >> (Page 9 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 によって変換されたページ (->オリジナル) /