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






Showing results of 240

<< < 1 .. 6 7 8 9 10 > >> (Page 8 of 10)
From: John H. <jd...@gm...> - 2007年09月07日 17:58:44
On 9/7/07, Matthieu Brucher <mat...@gm...> wrote:
>
> Thank you for the fast answer :)
> That should be what I asked for. Won't the other subplots be erased ?
Only if this subplots overlap -- in this case they do not. When a
previous subplot is overlapped by a new subplot, the old one is
erased.
JDH
From: Matthieu B. <mat...@gm...> - 2007年09月07日 17:34:24
>
> Although I am not completely sure what you are asking, I think you are
> asking for:
>
> subplot(221)
> subplot(222)
> subplot(212)
>
> then the last subplot (bottom row) will span both columns.
>
> JDH
>
Thank you for the fast answer :)
That should be what I asked for. Won't the other subplots be erased ?
Matthieu
From: John H. <jd...@gm...> - 2007年09月07日 17:30:58
On 9/7/07, Matthieu Brucher <mat...@gm...> wrote:
> Hi,
>
> I want to know if it is possible to create a plot on several subplots. For
> instance :
>
> pl.subplot(2, 2, 1)
> pl.plot(y1)
> pl.sublot(2, 2, 2)
> pl.plot(y2)
> pl.subplot(2, 2, ???) # Create a plot on the last line
> plot(y3)
>
> Is it possible ?
Although I am not completely sure what you are asking, I think you are
asking for:
subplot(221)
subplot(222)
subplot(212)
then the last subplot (bottom row) will span both columns.
JDH
From: Matthieu B. <mat...@gm...> - 2007年09月07日 14:17:31
Hi,
I want to know if it is possible to create a plot on several subplots. For
instance :
pl.subplot(2, 2, 1)
pl.plot(y1)
pl.sublot(2, 2, 2)
pl.plot(y2)
pl.subplot(2, 2, ???) # Create a plot on the last line
plot(y3)
Is it possible ?
Matthieu
From: Eduardo L. <ed...@bu...> - 2007年09月07日 13:02:32
Hello,
I am making an image using imshow, and adding xticks and xlabel, and then 
saving it with savefig. I'm supplying the xticks on a list as they have 
custom names. On the output file, I get the xlabel cutoff. I can only see 
the top of it. I tryed changing a number of things but none worked. How to 
deal with this?
Thanks,
-- 
Eduardo Lopez
Los Alamos National Lab
ed...@bu...
From: Steve S. <el...@gm...> - 2007年09月07日 06:47:09
Norbert Nemec wrote:
> 
>> 2) Is there a way to calculate the magnitude (length) of a vector?
> numpy.linalg.norm(X)
> 
This makes more sense than len(). I've got confused by "length" :)
-- 
cheers,
steve
I love deadlines. I like the whooshing sound they make as they fly by. --
Douglas Adams
From: Eric F. <ef...@ha...> - 2007年09月06日 19:17:30
If you are using the gd or paint backends, please speak up *now*, and 
tell me what the advantage is over the myriad other ways of generating 
png files with mpl. I would like to delete these backends *soon* unless 
there is some real advantage in keeping them.
Thanks.
Eric
From: Norbert N. <Nor...@gm...> - 2007年09月06日 19:09:25
Robert Dailey wrote:
> 1) Is there any way to represent vectors? Currently I'm using 'array'
> for vectors.
There is no explicit 'vector' representation. You may view vectors as
either column or row vectors and represent them as 1xN or Nx1 matrices.
In that case, the linear algebra like matrix products etc. can be used
rather elegantly. Otherwise, you just use 1D-arrays and take care of the
vector semantics yourself.
> 2) Is there a way to calculate the magnitude (length) of a vector?
numpy.linalg.norm(X)
(works for vectors as well as matrices)
From: Frank S. <b17...@gm...> - 2007年09月06日 00:54:38
Hi ,
I am plotting some date based data (dates/values).
Seems to work ok. The code snippet is below.
But what I am trying to do is set the font size of the (%b)
month labels (Jan,Feb etc) as they are too big for my small graph
and they run into each other ..
ax.xaxis.set_major_formatter( DateFormatter('%Y') )
ax.xaxis.set_major_locator( YearLocator() )
ax.xaxis.set_minor_formatter( DateFormatter('%b'))
ax.xaxis.set_minor_locator( MonthLocator(interval=1) )
ax.plot_date(dates,values, label="My 
Label",color='g',linestyle='-',marker='.')
Thanks / Frank
From: Steve S. <el...@gm...> - 2007年09月05日 20:51:36
Robert Dailey wrote:
> Hi,
> 
> I have two questions:
> 
> 1) Is there any way to represent vectors? Currently I'm using 'array' for
> vectors.
> 
I suppose you mean vectors in the Matlab way? Then you should have a look at
http://scipy.org/NumPy_for_Matlab_Users#head-e9a492daa18afcd86e84e07cd2824a9b1b651935
In short: of course you can do all linalg with numpy.array. With numpy.matrix,
some operations (like dot products) can be written more conveniently.
> 2) Is there a way to calculate the magnitude (length) of a vector?
> 
a = array([3,1,4])
len(a)
a.size # only for a rank-1 array
a.shape[0]
For some basics on numpy, you may also check out:
http://scipy.org/Documentation
HTH
-- 
cheers,
steve
I love deadlines. I like the whooshing sound they make as they fly by. --
Douglas Adams
From: Eric F. <ef...@ha...> - 2007年09月05日 19:50:02
Hal Huntley wrote:
> I'm a sys admin trying to install the matplotlib python package for someone
> on our staff. I'm not overly familar with python.
> 
> We are trying to use matplotlib with pylab. 
> 
> uname -a
> Linux andromeda 2.6.13-1.1532_FC4smp #1 SMP Thu Oct 20 01:51:51 EDT 2005
> i686 i686 i386 GNU/Linux
> 
> The python version we have is the default that we got with the Fedora Core 4
> package.
> 
> python -V
> Python 2.4.1
> 
> I've installed using /usr/bin/easy_install:
> matplotlib-0.90.1-py2.4-win32.egg numpy-1.0.3.1-py2.4-win32.egg
I've never understood eggs and easy_install, but it certainly doesn't 
look right that you are installing things labelled "win32" on a Linux 
box! I'm surprised you got that far.
For linux, I like to install from source, since the distro packages for 
numpy and mpl are usually too old. If you get the tarballs, build and 
install numpy first, then mpl. You don't need or want Numeric or 
numarray. The build process may fail. If it does, it is because you 
need to install distro packages with headers for various libraries, and 
you should be able to see from the failures which headers are missing.
Maybe someone else can provide more detailed instructions for Fedora C4.
Eric
> 
> If we get in to python and give the command:
>>>> from pylab import *
> 
> We get:
> ==
> Traceback (most recent call last):
> File "<stdin>", line 1, in ?
> File
> "/usr/lib/python2.4/site-packages/matplotlib-0.90.1-py2.4-win32.egg/pylab.py", line 1, in ?
> from matplotlib.pylab import *
> File
> "/usr/lib/python2.4/site-packages/matplotlib-0.90.1-py2.4-win32.egg/matplotlib/pylab.py", line 201, in ?
> import mlab #so I can override hist, psd, etc...
> File
> "/usr/lib/python2.4/site-packages/matplotlib-0.90.1-py2.4-win32.egg/matplotlib/mlab.py", line 64, in ?
> import nxutils
> File
> "/usr/lib/python2.4/site-packages/matplotlib-0.90.1-py2.4-win32.egg/matplotlib/nxutils.py", line 17, in ?
> from matplotlib._ns_nxutils import *
> File
> "/usr/lib/python2.4/site-packages/matplotlib-0.90.1-py2.4-win32.egg/matplotlib/_ns_nxutils.py", line 7, in ?
> __bootstrap__()
> File
> "/usr/lib/python2.4/site-packages/matplotlib-0.90.1-py2.4-win32.egg/matplotlib/_ns_nxutils.py", line 5, in __bootstrap__
> del __bootstrap__, __loader__
> NameError: global name '__loader__' is not defined
> ==
> 
> I've read that numeric may need to be installed, so I got "Numeric-24.2"
> and did:
> python setup.py build
> python setup.py install
> 
> That didn't help solve the issue.
> 
> Is there some other package that needs to be installed? I checked the FAQ
> and this issue does not seem to be there.
> 
> Regards,
> 
> Hal Huntley
> SRI International
> 
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc.
> Still grepping through log files to find problems? Stop.
> Now Search log events and configuration files using AJAX and a browser.
> Download your FREE copy of Splunk now >> http://get.splunk.com/
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: Eric F. <ef...@ha...> - 2007年09月05日 19:05:56
C M wrote:
> 
> 
> > x = [1,2,3]
> > y = [10,20,30]
> > self.subplot.plot(x, y)
> 
> I don't understand--where did "self" come from? 
> 
> 
> Sorry--"self" here refers to an instance of a wxPanel class in my 
> wxPython app.
> It is the parent window for the mpl subplot which is meant to be a child 
> of it.
> The subplot is itself a child of a Figure, so the creation is like this:
> 
> self.figure = Figure(None, dpi)
> self.subplot = self.figure.add_subplot(111)
add_subplot makes an Axes instance and puts it in the Figure instance; 
self.subplot is this Axes instance, as I had guessed. So, you can apply 
any Axes method to it.
Eric
From: Hal H. <ha...@so...> - 2007年09月05日 19:02:16
I'm a sys admin trying to install the matplotlib python package for someone
on our staff. I'm not overly familar with python.
We are trying to use matplotlib with pylab. 
uname -a
Linux andromeda 2.6.13-1.1532_FC4smp #1 SMP Thu Oct 20 01:51:51 EDT 2005
i686 i686 i386 GNU/Linux
The python version we have is the default that we got with the Fedora Core 4
package.
python -V
Python 2.4.1
I've installed using /usr/bin/easy_install:
matplotlib-0.90.1-py2.4-win32.egg numpy-1.0.3.1-py2.4-win32.egg
If we get in to python and give the command:
>>> from pylab import *
We get:
==
Traceback (most recent call last):
 File "<stdin>", line 1, in ?
 File
 "/usr/lib/python2.4/site-packages/matplotlib-0.90.1-py2.4-win32.egg/pylab.py", line 1, in ?
 from matplotlib.pylab import *
 File
 "/usr/lib/python2.4/site-packages/matplotlib-0.90.1-py2.4-win32.egg/matplotlib/pylab.py", line 201, in ?
 import mlab #so I can override hist, psd, etc...
 File
 "/usr/lib/python2.4/site-packages/matplotlib-0.90.1-py2.4-win32.egg/matplotlib/mlab.py", line 64, in ?
 import nxutils
 File
 "/usr/lib/python2.4/site-packages/matplotlib-0.90.1-py2.4-win32.egg/matplotlib/nxutils.py", line 17, in ?
 from matplotlib._ns_nxutils import *
 File
 "/usr/lib/python2.4/site-packages/matplotlib-0.90.1-py2.4-win32.egg/matplotlib/_ns_nxutils.py", line 7, in ?
 __bootstrap__()
 File
 "/usr/lib/python2.4/site-packages/matplotlib-0.90.1-py2.4-win32.egg/matplotlib/_ns_nxutils.py", line 5, in __bootstrap__
 del __bootstrap__, __loader__
NameError: global name '__loader__' is not defined
>>> 
==
I've read that numeric may need to be installed, so I got "Numeric-24.2"
and did:
 python setup.py build
 python setup.py install
That didn't help solve the issue.
Is there some other package that needs to be installed? I checked the FAQ
and this issue does not seem to be there.
Regards,
Hal Huntley
SRI International
From: C M <cmp...@gm...> - 2007年09月05日 18:24:55
> x = [1,2,3]
> > y = [10,20,30]
> > self.subplot.plot(x, y)
>
> I don't understand--where did "self" come from?
Sorry--"self" here refers to an instance of a wxPanel class in my wxPython
app.
It is the parent window for the mpl subplot which is meant to be a child of
it.
The subplot is itself a child of a Figure, so the creation is like this:
self.figure = Figure(None, dpi)
self.subplot = self.figure.add_subplot(111)
 If we assume that self.subplot is in fact an axes instance, then you can
> use
> self.subplot.plot_date(...), where the arguments would be the same as if
> you were using pylab.plot_date(...).
Is it? How is Figure() related to axes?
Maybe it would also help for you to look at dates.py (one of the mpl
> modules)?
I will try; so far, when I try to adapt the examples given in this thread to
an
wx embedded app it is not working...
Thanks,
Che
From: Patrick B. <pat...@gm...> - 2007年09月05日 18:20:53
Never mind - I missed a key point in the documentation. For anyone who's
wondering:
lg = legend()
lg.get_frame().set_facecolor('black')
works fine.
--Patrick
On 9/5/07, Patrick Bradley <pat...@gm...> wrote:
>
> Hi all,
>
> Can you change the background of the figure legends generated by
> matplotlib? I'd like to have some white-on-black figures for a few
> presentations that I'm giving, and I can change the figure and axes
> facecolor attributes accordingly (as well as the default text and axis label
> colors), but I can't find an option anywhere to change the background of the
> legend: it still shows up as a white box. Any ideas?
>
> Thanks in advance.
>
> Yours,
> Patrick
>
From: Eric F. <ef...@ha...> - 2007年09月05日 18:12:52
Ping Yeh wrote:
> 2007年9月5日, Eric Firing <ef...@ha...>:
>> Ping Yeh wrote:
>> [snip]
>>> If there is no existing modules for this I'll go ahead write one. :)
>> There is nothing quite like this. As a starting point, though, you
>> should become familiar with the ability of numpy to handle record
>> arrays; your table data type sounds like a numpy record array.
>> Matplotlib is a plotting library built on the numpy N-dimensional array
>> library.
>>
>> Eric
>>
> 
> Hi Eric,
> 
> Thanks for the info. I searched for the numpy record array and it is
> indeed very close to what I want for the data storage! Thanks!
> 
> Just one quick question, though (I admit I don't have much experience
> with numpy...). Can a record array store string data? I'll have some
> of these in the attribute data, not used for plotting but needed for
> other purposes.
Yes. Here is an example:
In [27]:dd1 = numpy.dtype({'names': ['x', 'y', 'i', 'comment'], 
'formats': ['<f8', '<f8', '<i4', 'S20']})
In [28]:xx = numpy.array([(1.1, 2.2, 1, 'first'), (1.2, 2.3, 2, 
'second')], dtype=dd1)
In [29]:xx
Out[29]:
array([(1.1000000000000001, 2.2000000000000002, 1, 'first'),
 (1.2, 2.2999999999999998, 2, 'second')],
 dtype=[('x', '<f8'), ('y', '<f8'), ('i', '<i4'), ('comment', 
'|S20')])
In [30]:xx['x']
Out[30]:array([ 1.1, 1.2])
In [31]:xx['comment']
Out[31]:
array(['first', 'second'],
 dtype='|S20')
There is one non-obvious thing to note: in line 28, each record must be 
a *tuple*, not a *list*.
Note also that you must allow enough space for the maximum length of 
string. Alternatively, the strings can be stored as objects:
In [32]:dd2 = numpy.dtype({'names': ['x', 'y', 'i', 'comment'], 
'formats': ['<f8', '<f8', '<i4', 'O']})
In [33]:xx = numpy.array([(1.1, 2.2, 1, 'first'), (1.2, 2.3, 2, 
'second')], dtype=dd2)
In [34]:xx['comment']
Out[34]:array([first, second], dtype=object)
In [35]:xx['x']
Out[35]:array([ 1.1, 1.2])
Eric
From: Patrick B. <pat...@gm...> - 2007年09月05日 17:59:36
Hi all,
Can you change the background of the figure legends generated by
matplotlib? I'd like to have some white-on-black figures for a few
presentations that I'm giving, and I can change the figure and axes
facecolor attributes accordingly (as well as the default text and axis label
colors), but I can't find an option anywhere to change the background of the
legend: it still shows up as a white box. Any ideas?
Thanks in advance.
Yours,
Patrick
From: Robert D. <rcd...@gm...> - 2007年09月05日 17:02:08
Hi,
I have two questions:
1) Is there any way to represent vectors? Currently I'm using 'array' for
vectors.
2) Is there a way to calculate the magnitude (length) of a vector?
Thanks.
From: Ping Y. <pin...@gm...> - 2007年09月05日 10:09:36
Hello,
Thanks to quick hints/tips from Eric and Lionel, I have a module for
conditional plotting and histogramming without defining a table type!
It works with numerical arrays quite well, but does not work on string
arrays in conditions.
I paste the code below since they are quite short. Hope that's not
considered spam on this list. :)
cheers and thanks,
Ping
from pylab import *
def __prepare(arg):
 cond = arg[-1]
 indices = find(cond)
 toplot = []
 atype = type(array([0,1]))
 for vec in arg[:-1]:
 if type(vec) == type(""): toplot.append(vec)
 if type(vec) == atype: toplot.append(array([vec[i] for i in indices]))
 return toplot
def cplot(*arg, **kw):
 '''Make a conditional plot. Example:
 cplot(t, x, y > 3) => a plot of { (t[i],x[i]) | y[i] > 3}
 cplot(x, y > 3) => a plot of { (i,x[i]) | y[i] > 3}
 The condition string can have multiple conditions joined by logical
 operators & | ^. All keyword arguments are passed intact to plot().
 '''
 toplot = __prepare(arg)
 return plot(*toplot, **kw)
def chist(*arg, **kw):
 '''Make a conditional histogram. Example:
 chist(x, y > 3) => a histogram plot of {x[i] | y[i] > 3}
 The condition string can have multiple conditions joined by logical
 operators & | ^. All keyword arguments are passed intact to hist().
 '''
 toplot = __prepare(arg)
 return hist(*toplot, **kw)
def testcplot():
 t = arange(0,1.0, 0.01)
 x = sin(t*2*pi)
 y = exp(-t/0.5)
 plot(t, x)
 plot(t, y)
 cplot(t, x, "o", y<0.2)
if __name__ == '__main__':
 testcplot()
From: Xavier G. <gn...@ob...> - 2007年09月05日 10:05:28
Eric Firing wrote:
> Xavier Gnata wrote:
>> Hi all,
>>
>> I looking for a way to modify the colorbar ticks font size.
>> a=rand(100,100)
>> imshow(a)
>> colorbar()
>> and then??
>>
>> For instance, xticks(fontsize=20) works well to modify the ticks 
>> fontsize along the X-axis but colorbar(fontsize=20) does not exists.
>> I must be missing something.
>
> cb = colorbar() # grab the Colorbar instance
> for t in cb.ax.get_yticklabels():
> t.set_fontsize(20)
>
> The colorbar function makes a new axes object, the "ax" attribute of 
> the Colorbar instance returned by the colorbar function. From that 
> you get the list of text objects, which you then modify.
>
> The pylab xticks and yticks functions make the retrieval and 
> modification of the text objects easier, but they operate only on the 
> "current axes", and the colorbar leaves the image axes as current.
>
> An alternative method is to change the current axes:
>
> imaxes = gca()
> axes(cb.ax)
> yticks(fontsize=20)
> axes(imaxes)
>
>
> Here I saved and restored the original axes in case you want to do 
> something with the image axes after modifying the colorbar.
>
> Eric
>
Hi,
Your first method is not working on my box (no change) but the second 
one is just fine :)
However, it is not as intuitive as other matplotlib ways of doing things.
Is there a simple way to modify the colorbar code to get something like 
colorbar(fontsize=20) work ?
Or maybe as a method like that : cb=colorbar() cb.set_fontsize(20)
Any comments ?
Xavier
-- 
############################################
Xavier Gnata
CRAL - Observatoire de Lyon
9, avenue Charles André
69561 Saint Genis Laval cedex
Phone: +33 4 78 86 85 28
Fax: +33 4 78 86 83 86
E-mail: gn...@ob...
############################################ 
From: Andres L. <and...@ut...> - 2007年09月05日 09:48:27
Hi all!
I'm new to matplotlib so please excuse me, if this is a bit too simple 
problem.
I'm trying to animate simple plot using example anim.py
It works well when I just write functions as follows:
def joonista(x):
 line, = p.plot(ala, x)
 p.draw()
 time.sleep(0.1)
def lpc(x):
 x2=empty(real(ap))
 for t in range(maxt):
 x2[alg]=x[alg+1]
 x2[ap-1]=x[alg]
 for k in range(alg+1,ap-1):
 x2[k]=x[k+1] 
 x=x2
 joonista(x2)
but when I write the functions in a more general way and define an 
additional function "lpc1" to make some calculation, like this:
def joonista(x):
 line, = p.plot(ala, x)
 p.draw()
 time.sleep(0.1)
def lpc(x):
 x2=empty(real(ap))
 for t in range(maxt):
 x2=lpc1(x) 
 x=x2
 joonista(x2)
def lpc1(x):
 x2=empty(real(ap))
 x2[alg]=x[alg+1]
 x2[ap-1]=x[alg]
 for k in range(alg+1,ap-1):
 x2[k]=x[k+1]
 return x2
the animation still works, but the plot does not clear itself at all, 
meaning that all the lines it draws stay there until the end. I'm using 
matplotlib version 0.87.1 which comes with ubuntu. The full code is 
added in the end.
So is this expected behavior and I should make the code in a different 
way or what? I could try to upgrade to newer version of matplotlib if 
that could be useful.
Regards,
Andres
The full program code:
#!/usr/bin/env python
import pylab as p
from numpy import *
import time
def joonista(x):
 line, = p.plot(ala, x)
 p.draw()
 time.sleep(0.1)
def gaussikover():
 for i in ala:
 x[i]=math.exp(-(i-ap2)**2./a)
 return x
def lpc(x):
 x2=empty(real(ap))
 for t in range(maxt):
## x2[alg]=x[alg+1]
## x2[ap-1]=x[alg]
## for k in range(alg+1,ap-1):
## x2[k]=x[k+1] 
 x2=lpc1(x) 
 x=x2
 joonista(x2)
def lpc1(x):
 x2=empty(real(ap))
 x2[alg]=x[alg+1]
 x2[ap-1]=x[alg]
 for k in range(alg+1,ap-1):
 x2[k]=x[k+1]
 return x2
p.ion()
alg=0
ap=100
ap2=ap/2
x=empty(real(ap))
a=70.
maxt=20
ala=range(ap)
x=gaussikover()
lpc(x)
From: Ping Y. <pin...@gm...> - 2007年09月05日 08:42:42
Hi Lionel,
Thanks for the tips. The histogram plot I need can be done by hist(x). :)
I tried your commands and I like the find() function! However,
xi = x[ind]
failed with an "IndexError: invalid index". The same operation can be done with
xi = array([x[i] for i in ind])
but if a numpy function can do that it may be faster for large arrays.
cheers,
Ping
2007年9月5日, Lionel Roubeyrie <lro...@li...>:
> Hi Ping,
> don't know if it could help you :
>
> from pylab import *
>
> > d = Table("xyt.dat")
> x,y,t = load("xyt.dat", unpack=true)
>
> > d.plot("x", "t") # make a plot of x vs. t, N points are drawn
> plot(t, x)
>
> > d.plot("x") # make a histogram plot of x, N entries in the histogram
> bar(range(len(x)), x)
>
> > d.plot("x", "y < 3") # make a histogram plot of x where y is less than 3.
> ind = find(y < 3)
> xi = x[ind]
> bar(range(len(xi)), xi)
>
> Cheers
>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc.
> Still grepping through log files to find problems? Stop.
> Now Search log events and configuration files using AJAX and a browser.
> Download your FREE copy of Splunk now >> http://get.splunk.com/
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
From: Ping Y. <pin...@gm...> - 2007年09月05日 08:33:23
2007年9月5日, Eric Firing <ef...@ha...>:
> Ping Yeh wrote:
> [snip]
> >
> > If there is no existing modules for this I'll go ahead write one. :)
>
> There is nothing quite like this. As a starting point, though, you
> should become familiar with the ability of numpy to handle record
> arrays; your table data type sounds like a numpy record array.
> Matplotlib is a plotting library built on the numpy N-dimensional array
> library.
>
> Eric
>
Hi Eric,
Thanks for the info. I searched for the numpy record array and it is
indeed very close to what I want for the data storage! Thanks!
Just one quick question, though (I admit I don't have much experience
with numpy...). Can a record array store string data? I'll have some
of these in the attribute data, not used for plotting but needed for
other purposes.
Thanks,
Ping
From: Lionel R. <lro...@li...> - 2007年09月05日 07:50:23
Hi Ping,
don't know if it could help you :
from pylab import *
> d = Table("xyt.dat")
x,y,t = load("xyt.dat", unpack=true)
> d.plot("x", "t") # make a plot of x vs. t, N points are drawn
plot(t, x)
> d.plot("x") # make a histogram plot of x, N entries in the histogram
bar(range(len(x)), x)
> d.plot("x", "y < 3") # make a histogram plot of x where y is less than 3.
ind = find(y < 3)
xi = x[ind]
bar(range(len(xi)), xi)
Cheers
From: Eric F. <ef...@ha...> - 2007年09月05日 07:46:36
C M wrote:
[...]
> So basically I need to use plot_date but in a figure embedded in a 
> wxPython app.
> Still not sure how this should be written. To make it simple, this 
> plot() command
> works in my app already:
> 
> x = [1,2,3]
> y = [10,20,30]
> self.subplot.plot(x, y)
I don't understand--where did "self" come from? If we assume that 
self.subplot is in fact an axes instance, then you can use 
self.subplot.plot_date(...), where the arguments would be the same as if 
you were using pylab.plot_date(...).
All this might be clarified if you look at the code for pylab.plot and 
pylab.plot_date.
I may be missing something; I was not paying attention to earlier parts 
of this thread, I haven't done much with dates and have never used 
plot_date myself, and I have no experience with embedding.
Maybe it would also help for you to look at dates.py (one of the mpl 
modules)?
Eric
> 
> So, my question is, how would this be modified for a wx app (that is, no 
> pylab
> allowed) and use plot_date()? Assume my dates are as given below.
> 
> dates (x axis): 
> 09-01-07 12:00:02
> 09-02-07 12:00:04
> 09-03-07 12:00:06
> 
> values (y axis):
> 10
> 20
> 30
> 
> The examples that Bill and Mark gave above in the list showed how to do
> this using pylab, but I just need the simplest example and one which does
> not use pylab.
> 
> Thanks,
> Che
> 
2 messages has been excluded from this view by a project administrator.

Showing results of 240

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