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



Showing 13 results of 13

From: Friedrich R. <fri...@gm...> - 2012年02月03日 20:34:18
> I am having troubles getting matplotlib to install. I have mac os X lion with Xcode 4.2.1 installed and I have used git to get the latest version of matplotlib. I am also running python 2.7.2 from the python.org site. The installation process was going fine based on the make.osx file supplied . The only thing I had to do was add a symbolic link to map gcc-4.2 to gcc to get it to compile, the I hit the following problem:
So what do you mean precisely by "the installation process was going fine" if you hit that complile error? So it did't go fine AISI, no?
> In file included from src/ft2font.cpp:3:
> src/ft2font.h:16:22: error: ft2build.h: No such file or directory
AFAIR this means it did't find the freetype2 installation sources. Either it's some mistake in make.osx or you did one. Can't say anything emphatically at this stage. Normally the make.osx installs the freetype2 somewhere. 
> src/ft2font.h:17:10: error: #include expects "FILENAME" or <FILENAME>
You could have a look which include that is. I don't have the sources here. 
Sorry for the slow reply. 
Friedrich
On 02/03/2012 06:07 AM, Benjamin Root wrote:
>
>
> On Fri, Feb 3, 2012 at 9:15 AM, Pål Gunnar Ellingsen <pa...@gm...
> <mailto:pa...@gm...>> wrote:
>
> Hi
>
> Thank you for trying to help me, though I can't see how aspect is going
> to help me. As I understand of the documentation, it would require
> me to know the
> relationship between x and y, which I don't.
> I can calculate it, but since it varies between each change in xlimits
> and different plot, it would be the same as calculating the ylimits.
>
> As for pyplot.xlim(xmin,xmax) (suggested by Ethan Swint), it does
> the same as ax.set_xlim() for me.
>
> Below is a sample code that will illustrate the problem.
>
> Regards
>
> Pål
>
> ####### Start code ############
>
> #!/usr/bin/env python
> import matplotlib
> matplotlib.use('Qt4Agg') # generate postscript output by default
>
> import matplotlib.pyplot as plt
> import numpy as np
>
> # Creating a function to plot
> x = np.linspace(-10, 10, 200)
> p = np.poly1d([2, 3, 1, 4])
> y = p(x) * np.sin(x)
>
> # plotting the full figure
> fig = plt.figure()
>
> ax = fig.add_subplot(111)
> ax.plot(x, y)
> ax.autoscale(tight=True)
> plt.title('Full graph. (Press key for next plot)')
> plt.draw()
>
> plt.waitforbuttonpress()
>
> # This is how I'm currently doing it
> # x limits
> xmin = 2
> xmax = 6
>
> # Calculating y limits
> ymin = y[np.logical_and(xmin < x, x < xmax)].min()
> ymax = y[np.logical_and(xmin < x, x < xmax)].max()
>
> # Inserting some room
> room = np.maximum(np.abs(ymin * 0.05), np.abs(ymax * 0.05))
> ymin = ymin + room * np.sign(ymin)
> ymax = ymax + room * np.sign(ymax)
>
> # Setting the limits
> ax.set_xlim([xmin, xmax])
> ax.set_ylim([ymin, ymax])
>
> plt.title('What I want (Press key for next plot)')
> plt.draw()
> plt.waitforbuttonpress()
>
> # This is what pyplot does by default if I only set the limits
> ax.autoscale(tight=True)
> ax.set_xlim([2, 6])
>
> plt.title('What I get if I only use set_xlim (Press key for exit)')
> plt.draw()
> plt.waitforbuttonpress()
> plt.close()
>
> ####### End code ############
>
>
>
> Ok, I see what you want. You want the y-limits to automatically change
> to fit only the data that is displayed for the x-domain you have chosen.
This has never been supported; it would have to be a new option. I 
suspect it would be quite difficult to get this right in general, even 
though the concept seems simple enough.
Eric
>
> I have tried some tricks, and I am not sure that it is currently
> possible. There might even be some sort of bug at play here because the
> function ax.update_datalim() does not appear to update the internal data
> used for autoscaling. We might have to look into this further.
>
> Ben Root
>
>
>
> ------------------------------------------------------------------------------
> Try before you buy = See our experts in action!
> The most comprehensive online learning library for Microsoft developers
> is just 99ドル.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
> Metro Style Apps, more. Free future releases when you subscribe now!
> http://p.sf.net/sfu/learndevnow-dev2
>
>
>
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: Benjamin R. <ben...@ou...> - 2012年02月03日 16:55:31
On Fri, Feb 3, 2012 at 10:27 AM, Saurav Pathak <sa...@sa...> wrote:
> Hi All,
>
> First, thanks for a very cool and pretty tool!
>
> My problem is, I have a 2D numpy array, say m by n, and I would like to
> display the data in n plots (with the same abscissa). That is, the 2D
> numpy array holds n time series data with m points each. I could use
> pyplot.plot inside a loop to display it, but n is very large as a result
> of which it takes a long time to create the plot and display it.
>
> Is there another way to do this more efficiently?
>
> Thanks,
> Saurav
>
>
Just pass in the 2D array as the 'y' argument. A line plot will be made
for each column in the 2D array and will even be automatically colored.
All lines will show up on the same axes.
Cheers!
Ben Root
Hi
Yes you've understood my problem correctly.
Let me know if there is anything I can do to help solve this issue.
Regards
Pål
On 3 February 2012 17:07, Benjamin Root <ben...@ou...> wrote:
>
>
> On Fri, Feb 3, 2012 at 9:15 AM, Pål Gunnar Ellingsen <pa...@gm...>wrote:
>
>> Hi
>>
>> Thank you for trying to help me, though I can't see how aspect is going
>> to help me. As I understand of the documentation, it would require me to
>> know the
>> relationship between x and y, which I don't.
>> I can calculate it, but since it varies between each change in xlimits
>> and different plot, it would be the same as calculating the ylimits.
>>
>> As for pyplot.xlim(xmin,xmax) (suggested by Ethan Swint), it does the
>> same as ax.set_xlim() for me.
>>
>> Below is a sample code that will illustrate the problem.
>>
>> Regards
>>
>> Pål
>>
>> ####### Start code ############
>>
>> #!/usr/bin/env python
>> import matplotlib
>> matplotlib.use('Qt4Agg') # generate postscript output by default
>>
>> import matplotlib.pyplot as plt
>> import numpy as np
>>
>> # Creating a function to plot
>> x = np.linspace(-10, 10, 200)
>> p = np.poly1d([2, 3, 1, 4])
>> y = p(x) * np.sin(x)
>>
>> # plotting the full figure
>> fig = plt.figure()
>>
>> ax = fig.add_subplot(111)
>> ax.plot(x, y)
>> ax.autoscale(tight=True)
>> plt.title('Full graph. (Press key for next plot)')
>> plt.draw()
>>
>> plt.waitforbuttonpress()
>>
>> # This is how I'm currently doing it
>> # x limits
>> xmin = 2
>> xmax = 6
>>
>> # Calculating y limits
>> ymin = y[np.logical_and(xmin < x, x < xmax)].min()
>> ymax = y[np.logical_and(xmin < x, x < xmax)].max()
>>
>> # Inserting some room
>> room = np.maximum(np.abs(ymin * 0.05), np.abs(ymax * 0.05))
>> ymin = ymin + room * np.sign(ymin)
>> ymax = ymax + room * np.sign(ymax)
>>
>> # Setting the limits
>> ax.set_xlim([xmin, xmax])
>> ax.set_ylim([ymin, ymax])
>>
>> plt.title('What I want (Press key for next plot)')
>> plt.draw()
>> plt.waitforbuttonpress()
>>
>> # This is what pyplot does by default if I only set the limits
>> ax.autoscale(tight=True)
>> ax.set_xlim([2, 6])
>>
>> plt.title('What I get if I only use set_xlim (Press key for exit)')
>> plt.draw()
>> plt.waitforbuttonpress()
>> plt.close()
>>
>> ####### End code ############
>>
>>
>>
> Ok, I see what you want. You want the y-limits to automatically change to
> fit only the data that is displayed for the x-domain you have chosen.
>
> I have tried some tricks, and I am not sure that it is currently
> possible. There might even be some sort of bug at play here because the
> function ax.update_datalim() does not appear to update the internal data
> used for autoscaling. We might have to look into this further.
>
> Ben Root
>
>
From: Saurav P. <sa...@sa...> - 2012年02月03日 16:44:23
Hi All,
First, thanks for a very cool and pretty tool!
My problem is, I have a 2D numpy array, say m by n, and I would like to 
display the data in n plots (with the same abscissa). That is, the 2D 
numpy array holds n time series data with m points each. I could use 
pyplot.plot inside a loop to display it, but n is very large as a result 
of which it takes a long time to create the plot and display it.
Is there another way to do this more efficiently?
Thanks,
Saurav
On Fri, Feb 3, 2012 at 9:15 AM, Pål Gunnar Ellingsen <pa...@gm...>wrote:
> Hi
>
> Thank you for trying to help me, though I can't see how aspect is going
> to help me. As I understand of the documentation, it would require me to
> know the
> relationship between x and y, which I don't.
> I can calculate it, but since it varies between each change in xlimits
> and different plot, it would be the same as calculating the ylimits.
>
> As for pyplot.xlim(xmin,xmax) (suggested by Ethan Swint), it does the same
> as ax.set_xlim() for me.
>
> Below is a sample code that will illustrate the problem.
>
> Regards
>
> Pål
>
> ####### Start code ############
>
> #!/usr/bin/env python
> import matplotlib
> matplotlib.use('Qt4Agg') # generate postscript output by default
>
> import matplotlib.pyplot as plt
> import numpy as np
>
> # Creating a function to plot
> x = np.linspace(-10, 10, 200)
> p = np.poly1d([2, 3, 1, 4])
> y = p(x) * np.sin(x)
>
> # plotting the full figure
> fig = plt.figure()
>
> ax = fig.add_subplot(111)
> ax.plot(x, y)
> ax.autoscale(tight=True)
> plt.title('Full graph. (Press key for next plot)')
> plt.draw()
>
> plt.waitforbuttonpress()
>
> # This is how I'm currently doing it
> # x limits
> xmin = 2
> xmax = 6
>
> # Calculating y limits
> ymin = y[np.logical_and(xmin < x, x < xmax)].min()
> ymax = y[np.logical_and(xmin < x, x < xmax)].max()
>
> # Inserting some room
> room = np.maximum(np.abs(ymin * 0.05), np.abs(ymax * 0.05))
> ymin = ymin + room * np.sign(ymin)
> ymax = ymax + room * np.sign(ymax)
>
> # Setting the limits
> ax.set_xlim([xmin, xmax])
> ax.set_ylim([ymin, ymax])
>
> plt.title('What I want (Press key for next plot)')
> plt.draw()
> plt.waitforbuttonpress()
>
> # This is what pyplot does by default if I only set the limits
> ax.autoscale(tight=True)
> ax.set_xlim([2, 6])
>
> plt.title('What I get if I only use set_xlim (Press key for exit)')
> plt.draw()
> plt.waitforbuttonpress()
> plt.close()
>
> ####### End code ############
>
>
>
Ok, I see what you want. You want the y-limits to automatically change to
fit only the data that is displayed for the x-domain you have chosen.
I have tried some tricks, and I am not sure that it is currently possible.
There might even be some sort of bug at play here because the function
ax.update_datalim() does not appear to update the internal data used for
autoscaling. We might have to look into this further.
Ben Root
From: Fabrice S. <si...@lm...> - 2012年02月03日 15:51:21
Le vendredi 03 février 2012 à 12:11 +0000, David Craig a écrit :
> Hi, I am using matplotlib to produce some spectrograms for seismic
> data. I am looking at a 10 day period with a sample rate of 20sps. I
> would like to have my spectrogram to be composed of 10 minute windows
> with an overlap of 90%. However when I try and run my script I run out
> of memory. I can produce the spectrogram for a maximum of 3 days
> before an error occurs. 
> I have also tried to produce a spectrogram for each day and stick them
> together using subplot, but I then get the error given below. Anyone
> know a way around this??
> Thanks,
> David
It seems that the MemoryError does not occur when computing the
spectrogram, but when rendering it. A quick rule of a thumb tells me
that you have to display an image that is 12000x14400:
 12000 frequencies, as you are using windows with 12000 samples
 (no padded assumed)
 14400 windows, due to the 90% overlap
Having a 4-channel for the RGBA image may throw the MemoryError.
Can you check by trying to "imshow" such an array ?
You can also reduce the overlap, the one you used lead to a spectrum
computation each minute...
Hi
Thank you for trying to help me, though I can't see how aspect is going
to help me. As I understand of the documentation, it would require me to
know the
relationship between x and y, which I don't.
I can calculate it, but since it varies between each change in xlimits
and different plot, it would be the same as calculating the ylimits.
As for pyplot.xlim(xmin,xmax) (suggested by Ethan Swint), it does the same
as ax.set_xlim() for me.
Below is a sample code that will illustrate the problem.
Regards
Pål
####### Start code ############
#!/usr/bin/env python
import matplotlib
matplotlib.use('Qt4Agg') # generate postscript output by default
import matplotlib.pyplot as plt
import numpy as np
# Creating a function to plot
x = np.linspace(-10, 10, 200)
p = np.poly1d([2, 3, 1, 4])
y = p(x) * np.sin(x)
# plotting the full figure
fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot(x, y)
ax.autoscale(tight=True)
plt.title('Full graph. (Press key for next plot)')
plt.draw()
plt.waitforbuttonpress()
# This is how I'm currently doing it
# x limits
xmin = 2
xmax = 6
# Calculating y limits
ymin = y[np.logical_and(xmin < x, x < xmax)].min()
ymax = y[np.logical_and(xmin < x, x < xmax)].max()
# Inserting some room
room = np.maximum(np.abs(ymin * 0.05), np.abs(ymax * 0.05))
ymin = ymin + room * np.sign(ymin)
ymax = ymax + room * np.sign(ymax)
# Setting the limits
ax.set_xlim([xmin, xmax])
ax.set_ylim([ymin, ymax])
plt.title('What I want (Press key for next plot)')
plt.draw()
plt.waitforbuttonpress()
# This is what pyplot does by default if I only set the limits
ax.autoscale(tight=True)
ax.set_xlim([2, 6])
plt.title('What I get if I only use set_xlim (Press key for exit)')
plt.draw()
plt.waitforbuttonpress()
plt.close()
####### End code ############
On 3 February 2012 15:21, Benjamin Root <ben...@ou...> wrote:
>
>
> On Friday, February 3, 2012, Pål Gunnar Ellingsen <pa...@gm...>
> wrote:
> > Hi
> >
> > I've got a plot, containing a graph.
> > I would like to look at certain parts of it.
> > To do this I zoom in on the x-axis using set_xlim()
> > Then I would like to call autoscale(axis='y') and have matplotlib
> > autoscale the y axis within the current x-axis.
> >
> > I've tried several ways of doing this, both with autoscale and
> set_ylim(auto=True)
> > but non of them have been able to do this, as they only autoscale y on
> the full graph.
> > In the end I ended up writing my own code for calculating the new ymin
> and ymax ans using set_ylim([ymin, ymax]),
> > but I feel that this should not be necessary.
> >
> > While googling for the a solution I found an earlier e-mail on the
> matplotlib list,
> >
> http://www.mail-archive.com/mat...@li.../msg19664.html
> > which describes the same problem, but was never answered.
> >
> > Is there any other solution for this that I've missed?
> >
> > Regards
> >
> > Pål
> >
>
> Actually, the autoscaling is working as it should in your case. By
> default, automatic limits will encompass all data plotted.
>
> The missing piece of your puzzle is specifying an aspect constraint.
> ax.set_aspect() will allow for some sort of relationship between the x and
> y axes to exist. For example, setting it to 'equal' means that limits are
> chosen such that a distance on the x axis is displayed the same way as the
> same distance in the y-axis. There are some other preset values and I
> think you can specify a float as well.
>
> This is what I can remember of the top of my head. I hope this helps!
>
> Ben Root
On Friday, February 3, 2012, Pål Gunnar Ellingsen <pa...@gm...> wrote:
> Hi
>
> I've got a plot, containing a graph.
> I would like to look at certain parts of it.
> To do this I zoom in on the x-axis using set_xlim()
> Then I would like to call autoscale(axis='y') and have matplotlib
> autoscale the y axis within the current x-axis.
>
> I've tried several ways of doing this, both with autoscale and
set_ylim(auto=True)
> but non of them have been able to do this, as they only autoscale y on
the full graph.
> In the end I ended up writing my own code for calculating the new ymin
and ymax ans using set_ylim([ymin, ymax]),
> but I feel that this should not be necessary.
>
> While googling for the a solution I found an earlier e-mail on the
matplotlib list,
>
http://www.mail-archive.com/mat...@li.../msg19664.html
> which describes the same problem, but was never answered.
>
> Is there any other solution for this that I've missed?
>
> Regards
>
> Pål
>
Actually, the autoscaling is working as it should in your case. By
default, automatic limits will encompass all data plotted.
The missing piece of your puzzle is specifying an aspect constraint.
 ax.set_aspect() will allow for some sort of relationship between the x and
y axes to exist. For example, setting it to 'equal' means that limits are
chosen such that a distance on the x axis is displayed the same way as the
same distance in the y-axis. There are some other preset values and I
think you can specify a float as well.
This is what I can remember of the top of my head. I hope this helps!
Ben Root
From: David C. <dcd...@gm...> - 2012年02月03日 12:11:29
Hi, I am using matplotlib to produce some spectrograms for seismic data. I
am looking at a 10 day period with a sample rate of 20sps. I would like to
have my spectrogram to be composed of 10 minute windows with an overlap of
90%. However when I try and run my script I run out of memory. I can
produce the spectrogram for a maximum of 3 days before an error occurs.
I have also tried to produce a spectrogram for each day and stick them
together using subplot, but I then get the error given below. Anyone know a
way around this??
Thanks,
David
Traceback (most recent call last):
 File
"/usr/lib/python2.7/site-packages/matplotlib/backends/backend_gtk.py", line
394, in expose_event
 self._render_figure(self._pixmap, w, h)
 File
"/usr/lib/python2.7/site-packages/matplotlib/backends/backend_gtkagg.py",
line 75, in _render_figure
 FigureCanvasAgg.draw(self)
 File
"/usr/lib/python2.7/site-packages/matplotlib/backends/backend_agg.py", line
394, in draw
 self.figure.draw(self.renderer)
 File "/usr/lib/python2.7/site-packages/matplotlib/artist.py", line 55, in
draw_wrapper
 draw(artist, renderer, *args, **kwargs)
 File "/usr/lib/python2.7/site-packages/matplotlib/figure.py", line 798,
in draw
 func(*args)
 File "/usr/lib/python2.7/site-packages/matplotlib/artist.py", line 55, in
draw_wrapper
 draw(artist, renderer, *args, **kwargs)
 File "/usr/lib/python2.7/site-packages/matplotlib/axes.py", line 1946, in
draw
 a.draw(renderer)
 File "/usr/lib/python2.7/site-packages/matplotlib/artist.py", line 55, in
draw_wrapper
 draw(artist, renderer, *args, **kwargs)
 File "/usr/lib/python2.7/site-packages/matplotlib/image.py", line 354, in
draw
 im = self.make_image(renderer.get_image_magnification())
 File "/usr/lib/python2.7/site-packages/matplotlib/image.py", line 569, in
make_image
 transformed_viewLim)
 File "/usr/lib/python2.7/site-packages/matplotlib/image.py", line 201, in
_get_unsampled_image
 x = self.to_rgba(self._A, self._alpha)
 File "/usr/lib/python2.7/site-packages/matplotlib/cm.py", line 194, in
to_rgba
 x = self.cmap(x, alpha=alpha, bytes=bytes)
 File "/usr/lib/python2.7/site-packages/matplotlib/colors.py", line 551,
in __call__
 rgba = np.empty(shape=xa.shape+(4,), dtype=lut.dtype)
MemoryError
Hi
I've got a plot, containing a graph.
I would like to look at certain parts of it.
To do this I zoom in on the x-axis using set_xlim()
Then I would like to call autoscale(axis='y') and have matplotlib
autoscale the y axis within the current x-axis.
I've tried several ways of doing this, both with autoscale and
set_ylim(auto=True)
but non of them have been able to do this, as they only autoscale y on the
full graph.
In the end I ended up writing my own code for calculating the new ymin and
ymax ans using set_ylim([ymin, ymax]),
but I feel that this should not be necessary.
While googling for the a solution I found an earlier e-mail on the
matplotlib list,
http://www.mail-archive.com/mat...@li.../msg19664.html
which describes the same problem, but was never answered.
Is there any other solution for this that I've missed?
Regards
Pål
From: Benjamin R. <ben...@ou...> - 2012年02月03日 01:19:52
On Thu, Feb 2, 2012 at 6:25 PM, Jerzy Karczmarczuk <
jer...@un...> wrote:
> Benjamin Root on my suggestion that one can use del instead of remove :
>
> There are methods for ax that properly handle removal of types of artists
> that have been attached to an axes. The above approach assumes that no
> other collections have been plotted that you wanted to keep. The approach
> I gave is a very surgical method that makes sure that only what is supposed
> to be removed gets removed. Both are valid, and their usefulness depends
> upon which view of the data you need (remove types of artists versus
> removing particular artists).
>
> Yes, absolutely.
> With just a little remark: remove is a Python function which *searches*
> the list for a given value. del uses indices, so
> del lst[10000]
> will be most probably faster than lst.remove(value), if this value happens
> to occur for the first time at index 10000. Unless Matplotlib uses a
> specially tuned version of remove.
>
>
Don't confuse Python's remove() method for lists with the remove() method
for matplotlib Artist (and subclassed Artists) objects. Collections are a
subclass of Artist, and remove() simply means "remove me from the Axes
object I was connected to". This is because an Axes object contains lists
to the artists, collections and others that have been attached to it, and
each Artist has a reference to the Axes object that it was connected to.
So, calling remove() on an Artist will do all the appropriate house-keeping.
matplotlib Artist objects do not implement __del__(), so deleting an Artist
before calling remove() will not properly disconnect all of the callbacks
and references. I suspect that the only reason why this works at all is
that there is a lot of usage of weakrefs and it so there might be enough
error-checking to keep everything from crashing.
Others who are much more familiar with the underlying architecture may be
able to comment better. In the meantime, the pedantic, better form of:
del ax.collections[:]
would be:
for item in ax.collections :
 item.remove()
del ax.collections[:]
>
>
>> Under Windows XP, ion() is not too
>> compatible with show().
>> TKAgg (by default), WXAgg and GTKAgg bomb Bens program (and without
>> draw() nothing is plotted).
>>
>>
> That would be a bug and should be reported (assuming that it is in the
> latest version). Make sure that you are using at least v1.0.1 (preferably
> v1.1.0) to make sure that show() should do what you want. Any version
> earlier than v1.0.1 is very unpredictable with respect to multiple show()
> calls.
>
> I use 1.1.0. (Python 2.7.2) I didn't report any bug because I didn't know
> whether this was a bug...
>
Then, please do report it.
> But there are more...
> The animation module uses various timers depending on the back-end. This
> is -- perhaps -- the result of the fact that Python standard Timer (a
> subclass of Thread) is, to say it mildly, rather weak. So, under Tk the
> system uses after(), wx offers its timers, etc. Timed animation works
> differently under various backends.
>
This should also be a new thread, and possibly a new bug report as well.
Ben Root
From: Jerzy K. <jer...@un...> - 2012年02月03日 00:25:20
Benjamin Root on my suggestion that one can use del instead of remove :
> There are methods for ax that properly handle removal of types of 
> artists that have been attached to an axes. The above approach 
> assumes that no other collections have been plotted that you wanted to 
> keep. The approach I gave is a very surgical method that makes sure 
> that only what is supposed to be removed gets removed. Both are 
> valid, and their usefulness depends upon which view of the data you 
> need (remove types of artists versus removing particular artists).
>
Yes, absolutely.
With just a little remark: remove is a Python function which *searches* 
the list for a given value. del uses indices, so
del lst[10000]
will be most probably faster than lst.remove(value), if this value 
happens to occur for the first time at index 10000. Unless Matplotlib 
uses a specially tuned version of remove.
>
> Under Windows XP, ion() is not too
> compatible with show().
> TKAgg (by default), WXAgg and GTKAgg bomb Bens program (and without
> draw() nothing is plotted).
>
>
> That would be a bug and should be reported (assuming that it is in the 
> latest version). Make sure that you are using at least v1.0.1 
> (preferably v1.1.0) to make sure that show() should do what you want. 
> Any version earlier than v1.0.1 is very unpredictable with respect to 
> multiple show() calls.
I use 1.1.0. (Python 2.7.2) I didn't report any bug because I didn't 
know whether this was a bug...
But there are more...
The animation module uses various timers depending on the back-end. This 
is -- perhaps -- the result of the fact that Python standard Timer (a 
subclass of Thread) is, to say it mildly, rather weak. So, under Tk the 
system uses after(), wx offers its timers, etc. Timed animation works 
differently under various backends.
Here:
http://users.info.unicaen.fr/~karczma/TEACH/Test/isingVZ.py
is a program which simulates/visualizes a simple-minded 2D Ising model 
(vectorized Metropolis Monte-Carlo; not *exactly* physical, but only 
mister Nobody is perfect...). It should update the picture dynamically, 
and my students can see how the ferromagnetic domains develop.
When run with Tk, OK. GTK and wx -- no. The animation runs, but the 
figure is frozen for many seconds, and it is updated when the Slider is 
activated. The autonomous refreshing of the image is much much slower 
than under TK. I don' understand what is happening...
Tested on Windows XP, and under Linux (Fedora). I repeat, the animation 
runs, this is a problem of refreshing the display.
Thank you, and all the best.
Jerzy Karczmarczuk

Showing 13 results of 13

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