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


Showing 10 results of 10

From: Michael M. F. <mf...@ph...> - 2008年07月07日 23:29:25
Why do you want to "fork" the process? If you just run it in the 
background it should have the desired effect:
<begin tst.py>
from pylab import *
x = linspace(-10,10,100) # or load data from a file.
y = sin(x)
plot(x,y)
show()
<end tst.py>
$ python tst.py&
Process remains in background running until the user closes the plot 
window, at which point it terminates.
Michael.
On 7 Jul 2008, at 2:30 PM, James K. Gruetzner wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> I'm not sure if this is the right venue for this question. I've 
> searched the
> archives, but without success so far. If this is covered there (or 
> elsewhere
> on the web), I'd apprciate a pointer to it so it doesn't duplicate 
> bandwidth
> here.
>
> Anyway, what I'd like to do is have a python script which reads 
> data from a
> file, displays an image/plot/whatever made from the data, and then 
> exits,
> keeping the image displayed.
>
> I'm running Fedora 8, python 2.5.1, and matplotlib 0.91.2-1.fc8 
> from the yum
> repository. Backend is set to GTKAgg in my matplotlibrc file.
>
> My initial attempt used the "double fork" method from the python 
> cookbook:
>
> - -------------Code follows----------------------
> if __name__ == "__main__":
>
> #From Python Cookbook
> try:
> pid = os.fork()
> if pid > 0:
> # Exit first parent
> sys.exit(0)
> except OSError, e:
> print >>sys.stderr, "fork #1 failed: %d (%s)" %(e.errno, 
> e.strerror)
> sys.exit(1)
>
> # Decouple from parent environment
> #os.chdir("/")
> os.setsid()
> os.umask(0)
>
> # Do second fork
> try:
> pid = os.fork()
> if pid > 0:
> # Exit from second parent; print eventual PID before exiting
> print "Image PID %d" % pid
> sys.exit(0)
> except OSError, e:
> print >>sys.stderr, "fork #2 failed: %d (%s)"%(e.errno, 
> e.strerror)
> sys.exit(1)
>
> # Start the main loop to display image
> main()
>
> - --------------END CODE--------------------------------------
>
> The main() function reads the values appropriately into the 
> variable "myarr",
> and then calls imshow and show:
>
> - ------------ Code follows -------------------
> :
> :
> pylab.imshow(myarr)
> pylab.show()
> - --------------END CODE--------------------------------------
>
> . . . and then exits.
>
> All works well until I try to kill the figure/image by clicking on 
> the X in
> the upper-right corner. It disappears alright, but the process 
> remains
> running, and I have to manually kill it with the kill -SIGTERM 
> <pid> command.
>
> I'd like the process to die when I close the window.
>
> I'm really an application programmer, not a system programmer, and 
> usually
> don't delve this deeply into process management, so I'm probably doing
> something extremely ignorant. Help is appreciated.
>
> Thanks!
>
> James
>
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.7 (GNU/Linux)
>
> iD8DBQFIcor8xOXthSHeGJIRAm/aAKC/SPQzocHigz2glpvtBJc0BcMU3ACfUTe0
> PM0fby8/z3YJcAj+Llb++ho=
> =NgA/
> -----END PGP SIGNATURE-----
>
>
> ---------------------------------------------------------------------- 
> ---
> Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
> Studies have shown that voting for your favorite open source project,
> along with a healthy diet, reduces your potential for chronic lameness
> and boredom. Vote Now at http://www.sourceforge.net/community/cca08
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: James K. G. <jk...@sa...> - 2008年07月07日 21:30:59
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
I'm not sure if this is the right venue for this question. I've searched the 
archives, but without success so far. If this is covered there (or elsewhere 
on the web), I'd apprciate a pointer to it so it doesn't duplicate bandwidth 
here. 
Anyway, what I'd like to do is have a python script which reads data from a 
file, displays an image/plot/whatever made from the data, and then exits, 
keeping the image displayed. 
I'm running Fedora 8, python 2.5.1, and matplotlib 0.91.2-1.fc8 from the yum 
repository. Backend is set to GTKAgg in my matplotlibrc file. 
My initial attempt used the "double fork" method from the python cookbook:
- -------------Code follows----------------------
 if __name__ == "__main__":
 #From Python Cookbook
 try:
 pid = os.fork()
 if pid > 0:
 # Exit first parent
 sys.exit(0)
 except OSError, e:
 print >>sys.stderr, "fork #1 failed: %d (%s)" %(e.errno, e.strerror)
 sys.exit(1)
 # Decouple from parent environment
 #os.chdir("/")
 os.setsid()
 os.umask(0)
 # Do second fork
 try:
 pid = os.fork()
 if pid > 0:
 # Exit from second parent; print eventual PID before exiting
 print "Image PID %d" % pid
 sys.exit(0)
 except OSError, e:
 print >>sys.stderr, "fork #2 failed: %d (%s)"%(e.errno, e.strerror)
 sys.exit(1)
 # Start the main loop to display image
 main()
 
- --------------END CODE--------------------------------------
The main() function reads the values appropriately into the variable "myarr",
and then calls imshow and show:
- ------------ Code follows -------------------
 :
 :
 pylab.imshow(myarr)
 pylab.show()
- --------------END CODE--------------------------------------
. . . and then exits. 
All works well until I try to kill the figure/image by clicking on the X in 
the upper-right corner. It disappears alright, but the process remains 
running, and I have to manually kill it with the kill -SIGTERM <pid> command.
I'd like the process to die when I close the window. 
I'm really an application programmer, not a system programmer, and usually 
don't delve this deeply into process management, so I'm probably doing 
something extremely ignorant. Help is appreciated.
Thanks!
 James
 
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
iD8DBQFIcor8xOXthSHeGJIRAm/aAKC/SPQzocHigz2glpvtBJc0BcMU3ACfUTe0
PM0fby8/z3YJcAj+Llb++ho=
=NgA/
-----END PGP SIGNATURE-----
From: Lubos V. <li...@vr...> - 2008年07月07日 19:06:09
hello,
> why is it actually not possible to do something like the following piece 
> of code?
> ioff()
> plot commands
> draw()
> ion()
actually, i did some test now (modification of the example 
http://www.scipy.org/Cookbook/Matplotlib/Animations site):
from pylab import *
ioff()
x = arange(0,2*pi,0.01) # x-array
line, = plot(x,sin(x))
draw()
displays nothing, then
ion()
for i in arange(1,200):
 line.set_ydata(sin(x+i/10.0)) # update the data
 draw() # redraw the canvas
displays nothing as well, but shows the same 'lag' as when running the 
whole code in interactive mode. that means that the data is processed, 
the graphics is plotted, just the window is not displayed.
i thought that ioff() is present exactly for this purpose. 
unfortunately, the documentation page
http://matplotlib.sourceforge.net/interactive.html
shows only an example where an image file is produced first with ioff(), 
the figure is closed and something is then displayed with ion().
when i later issue another plot() command (i.e., plot(random(20), 
random(20)), it is displayed and shows also the last part of the sin(x) 
plot...
the thing i want to achieve is maybe impossible - i'd just love to know 
why, or what am i doing wrong... i'm very grateful for any hints.
best,
lubos
-- 
Lubos _@_"
http://www.lubos.vrbka.net
From: Michael D. <md...@st...> - 2008年07月07日 17:50:03
I think this was just an oversight in the refactoring of transformations 
for 0.98. This should work now in SVN r5716. Look here if you want to 
patch your local copy -->
http://matplotlib.svn.sourceforge.net/viewvc/matplotlib?view=rev&revision=5716
Cheers,
Mike
Matthew Turk wrote:
> Hi there,
>
> I'm attempting to port some code over to matplotlib 0.98.x.
> Previously, I was able to do something like:
>
> axes_object.pcolormesh(x,y,v)
> axes_object.set_xscale('log')
> axes_object.set_yscale('log')
>
> and then save the figure. However, now this fails because the
> sequence of transformations it applies is not affine. (assert
> transform.is_affine in collections.py:QuadMesh.) If I want to have
> the same effect -- a log-spaced pcolormesh -- what is the appropriate
> sequence of calls? I'd like to avoid pre-applying the log and
> plotting on a linear-scale plot, as the code also overplots analytic
> functions in the same figure.
>
> Thanks!
>
> -Matt
>
> -------------------------------------------------------------------------
> Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
> Studies have shown that voting for your favorite open source project,
> along with a healthy diet, reduces your potential for chronic lameness
> and boredom. Vote Now at http://www.sourceforge.net/community/cca08
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
-- 
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA
From: Václav Š. <eu...@ar...> - 2008年07月07日 15:45:41
Hello,
I would like to get periodically updated plots: the data set grows at
some rate (5 numbers/sec) and I would like to update all plots I have
(may be multiple) once in 5 seconds, for example.
I thought of storing Figure objects after creating the plots, then
launch separate thread that would wake up every 5 seconds, copy data
from the source arrays to the Line2D instances (set_data(...)) and call
Figure.draw(..) to update the plot.
I have a few questions to that:
1. Would it be possible to do only shallow copy of the arrays that are
being plotted so that on redrawing the figure, chanes in the datasets
would be picked up automatically? If not, is Line2D.set_data(...) the
right approach?
2. How can I trigger autoscaling of the figure so that all data can be
displayed? Like the one happening when the figure is first drawn; in the
_ideal_ case deynamic autoscaling would be effected only if the graph
has the default zoom level, so that user-zoom is not reset at every redraw.
3. How do I iterate over all Figure instances (and, consequently, Line2D
instances) that are being displayed? Currently, I store Line2D's that
are returned by pylab.plot(...) to acces them later, but I think there
must be a better way,
I hope I was able to clearly express my problem. Do not hesitate to ask
for more information. Best regards,
Vaclav
From: Lubos V. <li...@vr...> - 2008年07月07日 14:57:46
hi,
> you can avoid (auto-)rescaling in matplotlib:
> -------------------------------------------------------------------------------------------------------
> import pylab
> ax = pylab.subplot(111, autoscale_on=False)
> # or for an already existing axes instance 'ax' : ax.set_autoscale_on(False)
> --------------------------------------------------------------------------------------------------------
this is exactly what i wanted, thanks!
> If you want to plot in background you have to skip interactive mode (up to my 
> knowledge). If you nevertheless would like to change the results you can use 
> pylab.show() as last line in your script and change you data via 
> event-control - something like:
> --------------------------------------------------------------------------------------
> def function(event):
> if event.key == "c":
> pylab.cla()
> elif event.key == "u":
> # update the data
> pass
> pylab.connect("key_press_event", function)
> pylab.show()
> ----------------------------------------------------------------------------------------
i don't know if i understand this correctly, but i think i cannot use 
this approach. i need to update the plot several times during the script 
(showing progress of an iterative procedure) - but pylab.show() causes 
the program to halt (until the window is closed).
why is it actually not possible to do something like the following piece 
of code?
ioff()
plot commands
draw()
ion()
best,
lubos
-- 
Lubos _@_"
http://www.lubos.vrbka.net
From: Matthias M. <Mat...@gm...> - 2008年07月07日 14:27:35
Hi lubos,
you can avoid (auto-)rescaling in matplotlib:
-------------------------------------------------------------------------------------------------------
import pylab
ax = pylab.subplot(111, autoscale_on=False)
# or for an already existing axes instance 'ax' : ax.set_autoscale_on(False)
--------------------------------------------------------------------------------------------------------
If you want to plot in background you have to skip interactive mode (up to my 
knowledge). If you nevertheless would like to change the results you can use 
pylab.show() as last line in your script and change you data via 
event-control - something like:
--------------------------------------------------------------------------------------
def function(event):
 if event.key == "c":
 pylab.cla()
 elif event.key == "u":
 # update the data
 pass
pylab.connect("key_press_event", function)
pylab.show()
----------------------------------------------------------------------------------------
best regards 
Matthias
On Monday 07 July 2008 14:57:30 Lubos Vrbka wrote:
> hi guys,
>
> is it somehow possible to force matplotlib (pylab) not to rescale the
> axes while adding some data to an existing plot? currently i have to do
> in a cycle (simplified example):
> for (all data):
> p_U_ij.append(pylab.plot(r, data)
> pylab.xlim((0, 10))
> pylab.ylim((-5,10))
>
> because after pylab.plot the plot axes are rescaled according to the
> data read in. i'd prefer setting it beforehand (with xlim, ylim) and
> then to do only pylab.plot in the cycle:
>
> pylab.xlim((0, 10))
> pylam.ylim((-5, 10))
> for (all data):
> p_U_ij.append(pylab.plot(r, data)
>
> is it somehow possible? even better would be to do the plotting in the
> background (not showing the window until the plotting is completely
> finished) - but i wasn't succesful in doing that. i'm using interactive
> mode because after creation of all plots using the code above, i'm
> updating the graphics during the calculation...
>
> thanks for any hints!
>
> best,
> lubos
From: Lubos V. <li...@vr...> - 2008年07月07日 12:57:42
hi guys,
is it somehow possible to force matplotlib (pylab) not to rescale the 
axes while adding some data to an existing plot? currently i have to do 
in a cycle (simplified example):
for (all data):
 p_U_ij.append(pylab.plot(r, data)
 pylab.xlim((0, 10))
 pylab.ylim((-5,10))
because after pylab.plot the plot axes are rescaled according to the 
data read in. i'd prefer setting it beforehand (with xlim, ylim) and 
then to do only pylab.plot in the cycle:
pylab.xlim((0, 10))
pylam.ylim((-5, 10))
for (all data):
 p_U_ij.append(pylab.plot(r, data)
is it somehow possible? even better would be to do the plotting in the 
background (not showing the window until the plotting is completely 
finished) - but i wasn't succesful in doing that. i'm using interactive 
mode because after creation of all plots using the code above, i'm 
updating the graphics during the calculation...
thanks for any hints!
best,
lubos
-- 
Lubos _@_"
http://www.lubos.vrbka.net
From: Laurent D. <lau...@gm...> - 2008年07月07日 12:28:12
Hello,
I've recently used the toolbar from wxAgg backend:
from matplotlib.backends.backend_wx import NavigationToolbar2Wx
 
I've got a problem when trying to freeze my app now because I get this
message when trying to invoke the toolbar:
 
Traceback (most recent call last):
 File "CommandPanel.pyo", line 80, in OnOpenFile
 File "AnalystPanel.pyo", line 33, in addPanel
 File "Filter.pyo", line 50, in createWidget
 File "A1Filter.pyo", line 70, in fillWidget
 File "matplotlib\backends\backend_wx.pyo", line 1548, in __init__
 File "matplotlib\backend_bases.pyo", line 1524, in __init__
 File "matplotlib\backends\backend_wx.pyo", line 1570, in _init_toolbar
 File "matplotlib\backends\backend_wx.pyo", line 1405, in _load_bitmap
IOError: Could not find bitmap file "mpl-data\images\home.png"; dying
 
It is really strange because I've put this in my setup.py:
import matplotlib
data_files = matplotlib.get_py2exe_datafiles()
 
So there is a directory mpl-data/images so should work.
(other files are well found like fonts etc.)
Any guys has had this issue? (Matplotlib 0.98.1)
 
Laurent
 
From: Robert C. <cim...@nt...> - 2008年07月07日 08:50:24
Eric Firing wrote:
> Robert Cimrman wrote:
>> Eric Firing wrote:
>>> I'm not sure if this is addressing your situation, but the simplest 
>>> way to adjust all font sizes is to use the rcParams dictionary, 
>>> either directly or via the matplotlibrc file. If the default font 
>>> sizes for various items are specified using "medium", "large", etc, 
>>> instead of with numerical values in points, then everything can be 
>>> scaled by changing the single value, font.size, which is the point 
>>> size corresponding to "medium".
>>
>> Yes, this certainly works, but only for future plots, no? Or it works 
>> also if a figure already exists and I want to play with the sizes to 
>> get something that looks nice?
> 
> You are correct, it is for future plots, not for interactive 
> experimentation with font sizes. An alternative, though, is to make a 
> very simple script with a test plot using rcParams, run that repeatedly 
> as needed to tune the values, and then use those values when making the 
> plots you want to keep.
Yep. That, or accessing the object properties specific for a given 
figure, as posted in my first message. I am by no means saying that the 
rcParams way is not sufficient, I just wanted to elaborate a bit on the 
findobj idea, as an alternative...
Thanks for your feedback,
r.
1 message has been excluded from this view by a project administrator.

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