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






Showing 17 results of 17

From: Eric F. <ef...@ha...> - 2005年07月14日 21:10:26
Christian,
>>
>> >>> import numarray as N
>> >>> from numarray.ieeespecial import isnan, nan
>> >>> import numarray.ma as ma
>> >>> a = N.array([1, 2, nan, 3, 4])
>> >>> b = ma.masked_where(isnan(a), a)
>>
>> Now you can plot b and it will have a gap in the middle.
>>
> 
> 
> I tried it as described above but plotting with pylab.plot results in an 
> error message:
> 
> MAError: Cannot automatically convert masked array to Numeric because data
> is masked in one or more locations.
> 
> Am I missing something?
> 
> Regards, Christian
> 
The problem is that you need to use numarray, not Numeric, as your 
numerix choice. In your matplotlibrc file, use
numerix : numarray # Numeric or numarray
instead of the default, which is Numeric.
Unfortunately, although there is some partial compatibility between 
Numeric and numarray, it does not extend to one being able to read 
masked arrays from the other, so you need to use one or the other 
consistently. And if you want to work with nans, then numarray is the 
one you need to use.
Eric
From: Jeff P. <jef...@se...> - 2005年07月14日 20:15:42
Thanks John that helps. What is required to import so that 'setp' may be
used. I'm using WXAgg backend. Python chokes when I call setp(...).
thanks again.
J
-----Original Message-----
From: John Hunter [mailto:jdh...@ni...] 
Sent: Thursday, July 14, 2005 11:12 AM
To: Jeff Peery
Cc: mat...@li...
Subject: Re: [Matplotlib-users] transparent symbols
>>>>> "Jeff" == Jeff Peery <jef...@se...> writes:
 Jeff> Great thank you. One more question. I also want to change
 Jeff> the tick mark attributes like color, fontsize, rotation
 Jeff> etc. I used these lines of code:
 axesA.set_yticklabels(axesA.get_xticklabels(), rotation=0, ....
 ^ ^
Not your question, but are you mixing up x and y here?
 Jeff> I get an error because get_ticklabels() returns an instance
 Jeff> of label strings, not the strings themselves. How can I
 Jeff> convert these into a useful string so the above code works?
 Jeff> Or is there a better way to do this?
There are several ways to customize these properties. One way is to
get a list of ticks and then customize them
 xticks = ax.xaxis.get_major_ticks()
 labels = [xtick.label1 for xtick in xticks]
 lines = [xtick.tick1line for xtick in xticks]
 setp(lines, linewidth=2)
 setp(labels, color='red', fontsize=20)
The Tick instances have the following attributes, as detailed here
http://matplotlib.sourceforge.net/matplotlib.axis.html#Tick
 tick1line : a Line2D instance
 tick2line : a Line2D instance
 gridline : a Line2D instance
 label1 : a Text instance
 label2 : a Text instance
 gridOn : a boolean which determines whether to draw the
tickline
 tick1On : a boolean which determines whether to draw the 1st
tickline
 tick2On : a boolean which determines whether to draw the 2nd
tickline
 label1On : a boolean which determines whether to draw tick label
 label2On : a boolean which determines whether to draw tick label
JDH
From: John H. <jdh...@ac...> - 2005年07月14日 19:38:08
I'm heading out of town for a mini-vacation, so if I don't answer your
emails, it doesn't mean I don't love you anymore :-)
Back at the end of next week -- hold down the fort!
JDH
From: John H. <jdh...@ac...> - 2005年07月14日 19:21:15
>>>>> "Mark" == Mark Bakker <ma...@gm...> writes:
 Mark> Hello - Anybody know how I get the current subplot
 Mark> parameters from a figure, i.e. the values defined in the rc
 Mark> file such as figure.subplot.left ?
Well, those are two different questions.
 Mark> how I get the current subplot parameters from a figure
In [3]: fig = figure()
In [4]: fig.subplotpars.left
Out[4]: 0.125
In [5]: fig.subplots_adjust(left=0.2)
In [6]: fig.subplotpars.left
Out[6]: 0.20000000000000001
 Mark> the values defined in the rc file such as
 Mark> figure.subplot.left ?
In [1]: from matplotlib import rcParams as pars
In [2]: pars['figure.subplot.left']
Out[2]: 0.125
JDH
From: Mark B. <ma...@gm...> - 2005年07月14日 19:14:08
Hello -
Anybody know how I get the current subplot parameters from a figure,
i.e. the values defined in the rc file such as figure.subplot.left ?
>>> gcf().WHAT ?
Thanks,
Mark
From: Werner F. B. <wer...@fr...> - 2005年07月14日 19:02:56
Hi John,
John Hunter wrote:
>>>>>>"Noko" == Noko Phala <np...@an...> writes:
> 
> 
> Noko> Can someone tell me how to successfully create an executable
> Noko> of a script that uses matplotlib? The example script in the
> Noko> documentation does not appear to work for my case. I keep
> Noko> missing modules, and everytime I add the missing module, a
> Noko> new one crops up. Much like the problems listed here:
> Noko> http://mail.python.org/pipermail/python-list/2005-February/267595.html
> Noko> My recent error message is:
> 
> Noko> Traceback (most recent call last):
> 
> Noko> File "Uranium_Leaching_ Modelv1.py", line 162, in ?
> 
> Noko> File "pylab.pyc", line 1, in ?
> 
> Noko> File "matplotlib\pylab.pyc", line 217, in ?
> 
> Noko> File "matplotlib\backends\__init__.pyc", line 24, in
> Noko> pylab_setup
> 
> Noko> ImportError: No module named backend_tkagg
> 
> Which backend do you want to use? Are you using the pylab interface.
> It looks like you are getting the default win32 backend backend_tkagg
> but you have explicitly excluded it with
> 
> "py2exe": {"excludes": ['_gtkagg', '_tkagg'],
> 
> It looks like you are using an old example, because these lines are
> not included in the examples pointed to in the FAQ. BTW, I have just
> tested and updated the py2exe example zip file so you may want
> download it 
> 
> http://matplotlib.sourceforge.net/faq.html#PY2EXE
> http://matplotlib.sourceforge.net/py2exe_examples.zip
> 
> The update includes an example for tkagg in addition to gtkagg and
> wxagg.
> 
> Note in the current release in matplotlib (0.83.1), before freezing,
> you need to replace these lines in
> site-packages/matplotlib/numerix/__init__.py
> 
> g = globals()
> l = locals()
> __import__('ma', g, l)
> __import__('fft', g, l)
> __import__('linear_algebra', g, l)
> __import__('random_array', g, l)
> __import__('mlab', g, l)
> 
> la = linear_algebra
> ra = random_array
> 
> 
> with the following
> 
> from matplotlib import FROZEN
> 
> if not FROZEN:
> g = globals()
> l = locals()
> __import__('ma', g, l)
> __import__('fft', g, l)
> __import__('linear_algebra', g, l)
> __import__('random_array', g, l)
> __import__('mlab', g, l)
> 
> la = linear_algebra
> ra = random_array
> 
> 
> because they break py2exe. These lines import the sub-modules of
> numerix (fft, ma, mlab, etc) into the numerix namespace. So you can
> do for example
> 
> import numerix as nx
> x = nx.mlab.mean( nx.mlab.randn(10000) 
> 
> 
> w/o them you have to explicitly import the submodules. Can anyone
> suggest a way to do this that doesn't break py2exe? Apparently py2exe
> doesn't handle __import__ very well.
I just added "matplotlib.numerix" to the packages line as follows.
"packages": ["encodings", "kinterbasdb", "pytz", "matplotlib.numerix"],
See you
Werner
> 
> JDH
> 
> 
> -------------------------------------------------------
> SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
> from IBM. Find simple to follow Roadmaps, straightforward articles,
> informative Webcasts and more! Get everything you need to get up to
> speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
From: John H. <jdh...@ac...> - 2005年07月14日 18:12:25
>>>>> "Jeff" == Jeff Peery <jef...@se...> writes:
 Jeff> Great thank you. One more question. I also want to change
 Jeff> the tick mark attributes like color, fontsize, rotation
 Jeff> etc. I used these lines of code:
 axesA.set_yticklabels(axesA.get_xticklabels(), rotation=0, ....
 ^ ^
Not your question, but are you mixing up x and y here?
 Jeff> I get an error because get_ticklabels() returns an instance
 Jeff> of label strings, not the strings themselves. How can I
 Jeff> convert these into a useful string so the above code works?
 Jeff> Or is there a better way to do this?
There are several ways to customize these properties. One way is to
get a list of ticks and then customize them
 xticks = ax.xaxis.get_major_ticks()
 labels = [xtick.label1 for xtick in xticks]
 lines = [xtick.tick1line for xtick in xticks]
 setp(lines, linewidth=2)
 setp(labels, color='red', fontsize=20)
The Tick instances have the following attributes, as detailed here
http://matplotlib.sourceforge.net/matplotlib.axis.html#Tick
 tick1line : a Line2D instance
 tick2line : a Line2D instance
 gridline : a Line2D instance
 label1 : a Text instance
 label2 : a Text instance
 gridOn : a boolean which determines whether to draw the tickline
 tick1On : a boolean which determines whether to draw the 1st tickline
 tick2On : a boolean which determines whether to draw the 2nd tickline
 label1On : a boolean which determines whether to draw tick label
 label2On : a boolean which determines whether to draw tick label
JDH
From: John H. <jdh...@ac...> - 2005年07月14日 18:06:55
>>>>> "andrea" == andrea gavana <and...@ti...> writes:
 >> I don't think that "plot" has the "set_data" attribute that I
 >> need in order to interact with every single point of the plot,
 >> but I may be wrong.
 >> 
 >> Andrea.
 andrea> Sorry, I have said something stupid. Of course I can use
 andrea> plot, now it's working. However, I have another (probably
 andrea> basic) question. In order to reverse the y-axis, for
 andrea> example, the only way I found is to get the minimum and
 andrea> the maximum of my data and then do something like:
 andrea> myaxes.set_ylim(mymax, mymin)
How about
 ymin, ymax = myaxes.get_ylim()
 myaxes.set_ylim(ymax, ymin)
JDH
 andrea> -------------------------------------------------------
 andrea> This SF.Net email is sponsored by the 'Do More With Dual!'
 andrea> webinar happening July 14 at 8am PDT/11am EDT. We invite
 andrea> you to explore the latest in dual core and dual graphics
 andrea> technology at this free one hour event hosted by HP, AMD,
 andrea> and NVIDIA. To register visit
 andrea> http://www.hp.com/go/dualwebinar
 andrea> _______________________________________________
 andrea> Matplotlib-users mailing list
 andrea> Mat...@li...
 andrea> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: John H. <jdh...@ac...> - 2005年07月14日 18:03:23
>>>>> "Tom" == Tom Denniston <tom...@gm...> writes:
 Tom> I have been using matplotlib as a replacement for MatLab and
 Tom> have had a great deal of success repicating basic plots. I
 Tom> was now trying to replicate some of the more value added
 Tom> functionality like the normplot and cdfplot. The normplot is
 Tom> particularly tricky because you need to scale the axises by
 Tom> the inverse normal cdf. There seems to be functionality to
 Tom> write scalers but the only ones that come with matplotlib out
 Tom> of the box are linear and log.
 Tom> Does anyone know how I might be able to achieve this
 Tom> functionality?
Unfortunately, mpl's transformation stuff is in C++, and is not a
terribly extensible design. It would be easy to add new functions to
the SeparableTransformation, but what you need is really a functional,
eg a class that is initialized with a set of values and transforms the
data accordingly. 
The place to start poking around is src/_transforms.h and
src/_transforms.cpp in the SeparableTransformation class. 
I'm out of town for the next week or so and will ruminate on this
while I'm away.
JDH
From: John H. <jdh...@ac...> - 2005年07月14日 17:51:01
>>>>> "Noko" == Noko Phala <np...@an...> writes:
 Noko> Can someone tell me how to successfully create an executable
 Noko> of a script that uses matplotlib? The example script in the
 Noko> documentation does not appear to work for my case. I keep
 Noko> missing modules, and everytime I add the missing module, a
 Noko> new one crops up. Much like the problems listed here:
 Noko> http://mail.python.org/pipermail/python-list/2005-February/267595.html
 Noko> My recent error message is:
 Noko> Traceback (most recent call last):
 Noko> File "Uranium_Leaching_ Modelv1.py", line 162, in ?
 Noko> File "pylab.pyc", line 1, in ?
 Noko> File "matplotlib\pylab.pyc", line 217, in ?
 Noko> File "matplotlib\backends\__init__.pyc", line 24, in
 Noko> pylab_setup
 Noko> ImportError: No module named backend_tkagg
Which backend do you want to use? Are you using the pylab interface.
It looks like you are getting the default win32 backend backend_tkagg
but you have explicitly excluded it with
 "py2exe": {"excludes": ['_gtkagg', '_tkagg'],
It looks like you are using an old example, because these lines are
not included in the examples pointed to in the FAQ. BTW, I have just
tested and updated the py2exe example zip file so you may want
download it 
 http://matplotlib.sourceforge.net/faq.html#PY2EXE
 http://matplotlib.sourceforge.net/py2exe_examples.zip
The update includes an example for tkagg in addition to gtkagg and
wxagg.
Note in the current release in matplotlib (0.83.1), before freezing,
you need to replace these lines in
site-packages/matplotlib/numerix/__init__.py
g = globals()
l = locals()
__import__('ma', g, l)
__import__('fft', g, l)
__import__('linear_algebra', g, l)
__import__('random_array', g, l)
__import__('mlab', g, l)
la = linear_algebra
ra = random_array
with the following
from matplotlib import FROZEN
if not FROZEN:
 g = globals()
 l = locals()
 __import__('ma', g, l)
 __import__('fft', g, l)
 __import__('linear_algebra', g, l)
 __import__('random_array', g, l)
 __import__('mlab', g, l)
 la = linear_algebra
 ra = random_array
because they break py2exe. These lines import the sub-modules of
numerix (fft, ma, mlab, etc) into the numerix namespace. So you can
do for example
import numerix as nx
x = nx.mlab.mean( nx.mlab.randn(10000) 
w/o them you have to explicitly import the submodules. Can anyone
suggest a way to do this that doesn't break py2exe? Apparently py2exe
doesn't handle __import__ very well.
JDH
From: John G. <jn...@eu...> - 2005年07月14日 12:26:54
I notice that pygtk.require('2.0') calls have appeared in backend_gtk.py 
and backend_gdk.py
I am not convinced that library code should include calls to pygtk.require()
The problem is that pygtk.require() has to be called >before< importing gtk.
This means that if you are using gtk then you have two choices:
 1. never use pygtk.require()
 2. always precede any 'import gtk' with 'import pygtk' and 
 'pygtk.require('2.0')'
I have found that 1. works pretty well and prefer not to litter code 
with the pygtk.require() boiler plate.
Unfortunately, approach 1. falls over if you use some library that 
decides to use pygtk.require().
In the times when I do require a specific version of pygtk then I can 
always create a simple wrapper that does the pygtk require stuff.
Now no doubt I'm missing some subtleties as to why it is good to have 
these pygtk.require() calls in matplotlib. Is there any way to make 
them optional?
A half-way house would be to do something like this:
try:
 import pygtk
 if not matplotlib.FROZEN and not sys.modules.has_key('gtk'):
 pygtk.require('2.0')
except:
 print >> sys.stderr, sys.exc_info()[1]
 raise SystemExit('PyGTK version %d.%d.%d or greater is required to run '
 'the GTK Matplotlib backends'
 % pygtk_version_required)
This code would ensure that the correct pygtk is loaded for people who 
haven't already import'ed gtk without throwing an exception for those 
that have loaded gtk prior to importing matplotlib.
The down side with this fix is that it doesn't help anyone who does want 
the pygtk.require() but has made the mistake of importing gtk first.
Any thoughts?
John
From: Noko P. <np...@an...> - 2005年07月14日 10:00:06
Can someone tell me how to successfully create an executable of a script
that uses matplotlib? The example script in the documentation does not
appear to work for my case. I keep missing modules, and everytime I add
the missing module, a new one crops up. Much like the problems listed
here:
http://mail.python.org/pipermail/python-list/2005-February/267595.html
My recent error message is:
Traceback (most recent call last):
 File "Uranium_Leaching_ Modelv1.py", line 162, in ?
 File "pylab.pyc", line 1, in ?
 File "matplotlib\pylab.pyc", line 217, in ?
 File "matplotlib\backends\__init__.pyc", line 24, in pylab_setup
ImportError: No module named backend_tkagg
=20
=20
The relevant parts of my setup.py script look like this:
data=3Dglob.glob(r'C:\Python23\share\matplotlib\*')
data.append(r'C:\Python23\share\matplotlib\matplotlibrc')
=20
options =3D {
 "py2exe": {"excludes": ['_gtkagg', '_tkagg'],
 "dll_excludes": ['libgdk-win32-2.0-0.dll',
'libgobject-2.0-0.dll'],
=20
 "includes": ['scipy','scipy.integrate','matplotlib.*',
 'scipy.special.*','scipy.linalg.*','scipy.*',\
 ],
 "packages":
['encodings','matplotlib.numerix.random_array','pytz',\
 'dateutil'
=20
=20
 Thanks,
Noko
=20
=20
Dr Noko Phala
Process Research
Anglo American Research Laboratories
8 Schonland Street
Theta Johannesburg
PO Box 106 Crown Mines 2025
Republic of South Africa
Tel: +27 (11) 377 4817
e-mail: np...@an...=20
 =20
=20
---------------------------------------------------------------------------=
---------------
This e-mail was checked by the e-Sweeper Service.
For more information visit our website, Clearswift Corporation e-Sweeper :
http://www.mimesweeper.com/products/esweeper/
---------------------------------------------------------------------------=
---------------
From: Torsten B. <br...@ph...> - 2005年07月14日 09:13:36
Hallöchen!
John Hunter <jdh...@ac...> writes:
>>>>>> "Torsten" == Torsten Bronger <br...@ph...> writes:
>
> Torsten> However, the datalim seems so implicitly include
> Torsten> zero. For example, if min(y_values) is 3, I still
> Torsten> see the point of origin. How can I avoid this
> Torsten> behaviour?
>
> We're just doing what we're told here :-)
>
> Your first plot call is
>
> y_values = total_number_values * [0.0]
> line, = plot(x_values, y_values)
>
> So zero is *explicitly* included. The datalim remember the
> history of objects have have been added. If you want them to
> ignore their history, call
>
> ax.dataLim.update_numerix(x_values, y_values, True)
Thank you, this problem is solved.
I had a look at anim_tk.py, mostly because I hoped that it solved
another issue, which it doesn't:
Again Windows, again TkAgg (although WXAgg shows the same
behaviour). The window with the animated plot has an hour glass
mouse pointer all the time (this is not the bad thing), and it
cannot be brought in front of the other windows. Even if I minimize
all other windows, only the being-updated part of the plot window is
intact, whereas the rest contains patches of the minimized windows.
Can one do something about it?
Tschö,
Torsten.
-- 
Torsten Bronger, aquisgrana, europa vetus
From: Christian K. <ck...@ho...> - 2005年07月14日 09:03:14
Hi Eric,
Eric Firing wrote:
> Again, the problem is that automatic masking of nans would be easy with 
> numarray but not at all easy with Numeric. Given that mpl is designed 
> to work the same with numarray and Numeric, it is not easy to build good 
> nan support into mpl. This will change when the successor to Numeric 
> becomes common enough that support for old Numeric can be dropped, but 
> not soon. In the meantime, if you want to use nans, you can do 
> something like this:
> 
> >>> import numarray as N
> >>> from numarray.ieeespecial import isnan, nan
> >>> import numarray.ma as ma
> >>> a = N.array([1, 2, nan, 3, 4])
> >>> b = ma.masked_where(isnan(a), a)
> 
> Now you can plot b and it will have a gap in the middle.
> 
I tried it as described above but plotting with pylab.plot results in an error
message:
MAError: Cannot automatically convert masked array to Numeric because data
 is masked in one or more locations.
Am I missing something?
Regards, Christian
From: Robert K. <rk...@uc...> - 2005年07月14日 06:23:48
Graeme O'Keefe wrote:
> Hi,
> 
> I know this really belongs on the sourceforge.net:numarray list, but it 
> is a very inactive list.
It's still the right place to ask. Your question would get answered in a 
timely manner. We're quiet; we're not gone. :-)
Followup-to has been reset.
> I have noted the following with numarray:
> 
> >>> x = numarray.zeros([3,3], numarray.Int16)
> >>> i = [0,1,2,0,1,2]
> >>> j = [0,1,2,0,1,2]
> >>> x[i, j] += 1
> >>> print x
> [[1, 0, 0]
> [0, 1, 0]
> [0, 0, 1]]
> I was expecting (hoping)
> [[2, 0, 0]
> [0, 2, 0]
> [0, 0, 2]]
> 
> which is what you obviously get if you:
> 
> for n in range(len(i)) : x[i[n], j[n]] += 1
> 
> This is the sort of operation one does all the time when histogramming 
> data-streams. Is there a way to achieve this without looping over i/j.
This has been discussed recently on the numpy-discussion list (Subject: 
vectorizing histogram-like computation). The semantics of array indexing 
aren't anything like that for loop. I doubt that the two kinds of 
semantics could be merged consistently.
 x[i,j] += 1
is closer to
 x[i,j] = x[i,j] + 1
which amounts, in this case, to
 x[i,j] = array([1, 1, 1, 1, 1, 1])
There's nothing in this last operation to suggest that the numbers ought 
to be added together (and if the initial values weren't zero, a more 
complicated operation would have to considered).
In short, I consider it cleaner to keep specialized histogram code 
tucked away in a function which you can eventually optimize to C as 
required.
-- 
Robert Kern
rk...@uc...
"In the fields of hell where the grass grows high
 Are the graves of dreams allowed to die."
 -- Richard Harter
From: Graeme O'K. <gj...@ne...> - 2005年07月14日 05:31:56
Hi,
I know this really belongs on the sourceforge.net:numarray list, but 
it is a very inactive list.
I have noted the following with numarray:
 >>> x = numarray.zeros([3,3], numarray.Int16)
 >>> i = [0,1,2,0,1,2]
 >>> j = [0,1,2,0,1,2]
 >>> x[i, j] += 1
 >>> print x
[[1, 0, 0]
 [0, 1, 0]
[0, 0, 1]]
I was expecting (hoping)
[[2, 0, 0]
 [0, 2, 0]
 [0, 0, 2]]
which is what you obviously get if you:
for n in range(len(i)) : x[i[n], j[n]] += 1
This is the sort of operation one does all the time when 
histogramming data-streams. Is there a way to achieve this without 
looping over i/j.
cheers,
Graeme
From: Tom D. <tom...@gm...> - 2005年07月14日 01:40:54
I have been using matplotlib as a replacement for MatLab and have had
a great deal of success repicating basic plots. I was now trying to
replicate some of the more value added functionality like the normplot
and cdfplot. The normplot is particularly tricky because you need to
scale the axises by the inverse normal cdf. There seems to be
functionality to write scalers but the only ones that come with
matplotlib out of the box are linear and log.
Does anyone know how I might be able to achieve this functionality?
--Tom

Showing 17 results of 17

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