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

Showing 5 results of 5

From: John H. <jdh...@ac...> - 2004年07月06日 20:28:50
>>>>> "danny" == danny shevitz <dan...@ya...> writes:
 danny> I tried to implement a simple .matplotlibrc file. The
 danny> contents are: #figure.figsize:12,9 lines.linewidth:1.0
 danny> I get the following traceback:
You are trying to load backend gtk and don't have it installed. You
should not implement your own rc file, but rather edit the one in
 C:\Python23\share\matplotlib\.matplotlibrc
(or wherever python is installed). This is discussed in the rc file
header, also found at http://matplotlib.sourceforge.net/.matplotlibrc.
Once you have edited it, move it to another directory, your HOME dir.
On win32, you will need to set the HOME environment variable to point
to this dir. If you edit it in place, it will work, but will be
overwritten next time you install matplotlib.
My best guess is you mangled the rc file and your backend is being set
to backend_gtk or backend_gtkagg. If indeed you want gtk or gtkagg,
my second guess is that you haven't properly installed the pygtk
prereqs.
JDH
From: John H. <jdh...@ac...> - 2004年07月06日 20:16:24
>>>>> "danny" == danny shevitz <dan...@ya...> writes:
 danny> John, First things first. Thanks for all your help. I
 danny> wasn't aware of the figlegend command (even though it is
 danny> clearly in the documentation). I can do what I want with
 danny> figlegends althought it takes some fiddling to get the
 danny> positions right. I have to use explicit coordinates because
 danny> the legends are referenced to the figure not the axes so
 danny> the boxes don't default to lying inside the graphs and
 danny> cross over the axes boundaries. In addition the legends
 danny> are in separate boxes with figlegend, which is acceptable,
 danny> but not necessarily optimal. I did run into another problem
 danny> using figlegend, namely that I can't get a handle to the
 danny> legend text so I'm not able to set the fontsize. I'd
 danny> appreciate it if you could illuminate me with how to set
 danny> fontsize in a figlegend.
The way to come to this knowledge is:
 1) look at the return value of the figlegend command - in this case
 the docs don't say what they are, but you can always print
 type(ret) or simply print(ret) where ret is the return value of
 figlegend to get an idea. I've updated the docs to state
 A matplotlib.legend.Legend instance is returned
 2) Go to the class documentation, either by doing
 help(ret) from the python shell or going to
 http://matplotlib.sourceforge.net/classdocs.html and clicking on
 the legend link
 http://matplotlib.sourceforge.net/matplotlib.legend.html.
 3) Peruse the docs for Legend: in this case you'll see
 get_frame(self)
 return the Rectangle instance used to frame the legend
 get_lines(self)
 return a list of lines.Line2D instances in the legend
 get_patches(self)
 return a list of patch instances in the legend
 get_texts(self)
 return a list of text.Text instance in the legend
So you can do
 leg = figlegend(blah, blah)
 texts = leg.get_texts() # get a sequence of legend texts
 lines = leg.get_lines() # get a sequence of legend lines
 patches = leg.get_patches() # get a sequence of legend patches
I don't mind you asking - I'm just trying to give you some pointers
for future reference.
 danny> In addition the legends are in separate boxes with
 danny> figlegend, which is acceptable, but not necessarily
 danny> optimal.
Not sure exactly what you mean. You can put them in the same box by
controlling the list of handles and text strings you pass figlegend,
or you can turn the legend frames off....
 leg.draw_frame(False)
 danny> So, on to other things. I cooked up an example that shows
 danny> what I was originally trying to do. I have two routines,
 danny> doPlots1 and doPlots2, that do exactly the same thing. The
 danny> only difference is in the default arguments, which I don't
 danny> actually set, I just use the default. Figure 1 has the
 danny> effect I was looking for, although I for the life of me
 danny> don't understand why the two routines give difference
 danny> answers, or for that matter, why figure 1 works the way it
 danny> does.
 danny> In any case. Figure 1 is what I was shooting for. If you
 danny> want to post some reliable code that does this, I'd
 danny> appreciate it.
See my comments below:
from matplotlib.matlab import *
import Numeric as N
# It is bad form to import Numeric or numarray after importing
# matplotlib. This is what numerix is for. You should use import
# matplotlib.numerix as N if you want to namespace Numeric. The
# command from matplotlib.matlab import * already imports all the
# numerix symbols.
def doPlots1(const,color,legendList=[],legendTextList=[]):
# In passing the empty list as a default argument, you are sharing the
# list between function calls. This explains why doPlots1 *works* and
# doPlots2 doesn't. This is a well know gotcha. The default
# arguments are evaluated *only once* at module load time, so
# legendList and legendText list are *the same* lists between function
# calls
	y1=N.arange(0., 10, 1)+ const
	x = arange(len(y1))
	
 	ln1 = plot(x,y1,color+'+-')
	legendList.append(ln1)
# ln1 is a length 1 list, not a line! You should do (note the comma)
#
# ln1, = plot(x,y1,color+'+-')
#
# to unpack the length one sequence. You only get a way with it
# because legend flattens the list for you
	legendTextList.append('line1')
	
	y2 = y1 + 1
	ln2 = plot(x,y2,color+'^-')
	legendList.append(ln2)
	legendTextList.append('line2')
	legend(legendList,legendTextList)
	show()
# You should only call "show" once per script. I repeat, you should
# only call "show" once per script. If you want to force a redraw use
# get_current_fig_manager().canvas.draw(). The next matplotlib
# release defines a "draw" function for this purpose.
	
def doPlots2(const,color):
	legendList=[]
	legendTextList=[]	
# Here legendList and legendTextList are local to the function, not
# shared between function calls
	y1=N.arange(0., 10, 1)+ const
	x = arange(len(y1))
	
	ln1 = plot(x,y1,color+'+-')
	legendList.append(ln1)
	legendTextList.append('line1')
	
	y2 = y1 + 1
	ln2 = plot(x,y2,color+'^-')
	legendList.append(ln2)
	legendTextList.append('line2')
	legend(legendList,legendTextList)
	show()
figure(1)	
doPlots1(0,'r')
doPlots1(5,'b')
figure(2)	
doPlots2(0,'r')
doPlots2(5,'b')
 danny> In any case. Figure 1 is what I was shooting for. If you
 danny> want to post some reliable code that does this, I'd
 danny> appreciate it.
While I don't know exactly what you are shooting for, the code below
replicates what Figure 1 looks like after your second call to
doPlots1.
from matplotlib.matlab import *
handles = []
labels = []	
for const, color in ( (0, 'r'), (5, 'b') ):
 y1 = arange(0., 10, 1)+ const
 x = arange(len(y1))
 y2 = y1 + 1
 lines = plot(x, y1, color+'+-', x, y2, color+'^-' )
 handles.extend(lines)
 labels.extend(('line1', 'line2'))
legend(handles, labels, 'upper left')
show()
Here's another approach using the label keyword arg
from matplotlib.matlab import *
handles = []
labels = []	
for const, color in ( (0, 'r'), (5, 'b') ):
 y1 = arange(0., 10, 1)+ const
 x = arange(len(y1))
 y2 = y1 + 1
 plot(x, y1, color+'+-', label='line1')
 plot(x, y2, color+'^-', label='line2' )
legend()
show()
Hope this helps!
JDH
From: danny s. <dan...@ya...> - 2004年07月06日 20:08:43
I tried to implement a simple .matplotlibrc file. The contents are:
#figure.figsize:12,9
lines.linewidth:1.0
I get the following traceback:
No module named pygtk
matplotlib requires pygtk-1.99.16 or greater -- trying anyway. Please
hold on
Traceback (most recent call last):
 File
"E:\projects\GeoFrag\sampleSimulations\cylinderTarget\cylinderTarget.py",
 line 10, in ?
 from nbe.simulation import Simulation
 File "E:\projects\geoFrag\nbe\simulation\__init__.py", line 1, in ?
 from simulation import Simulation
 File "E:\projects\geoFrag\nbe\simulation\simulation.py", line 1, in ?
 from nbe.treeFragments import cylinderFragmentationFactory
 File "E:\projects\geoFrag\nbe\treeFragments\__init__.py", line 10, in
?
 from cylinderFragmentation import CylinderFragmentation
 File
"E:\projects\geoFrag\nbe\treeFragments\cylinderFragmentation.py", line
7,
 in ?
 from nbe.fragments import fragmentFactory
 File "E:\projects\geoFrag\nbe\fragments\__init__.py", line 8, in ?
 from fragmentLists import FragmentLists
 File "E:\projects\geoFrag\nbe\fragments\fragmentLists.py", line 9, in
?
 from matplotlib.matlab import *
 File "D:\ENTHOU~1\Lib\site-packages\matplotlib\matlab.py", line 134,
in ?
 from backends import new_figure_manager, error_msg, \
 File "D:\ENTHOU~1\Lib\site-packages\matplotlib\backends\__init__.py",
line 16,
 in ?
 from backend_gtk import \
 File
"D:\ENTHOU~1\Lib\site-packages\matplotlib\backends\backend_gtk.py",
line
13, in ?
 import gobject
ImportError: No module named gobject
Any help would be appreciated.
thanks,
Danny
		
__________________________________
Do you Yahoo!?
Yahoo! Mail is new and improved - Check it out!
http://promotions.yahoo.com/new_mail
From: danny s. <dan...@ya...> - 2004年07月06日 18:09:15
John, 
First things first. Thanks for all your help. I wasn't aware of the
figlegend command (even though it is clearly in the documentation). I
can do what I want with figlegends althought it takes some fiddling to
get the positions right. I have to use explicit coordinates because the
legends are referenced to the figure not the axes so the boxes don't
default to lying inside the graphs and cross over the axes boundaries.
In addition the legends are in separate boxes with figlegend, which is
acceptable, but not necessarily optimal. I did run into another problem
using figlegend, namely that I can't get a handle to the legend text so
I'm not able to set the fontsize. I'd appreciate it if you could
illuminate me with how to set fontsize in a figlegend.
So, on to other things. I cooked up an example that shows what I was
originally trying to do. I have two routines, doPlots1 and doPlots2,
that do exactly the same thing. The only difference is in the default
arguments, which I don't actually set, I just use the default. Figure 1
has the effect I was looking for, although I for the life of me don't
understand why the two routines give difference answers, or for that
matter, why figure 1 works the way it does. 
In any case. Figure 1 is what I was shooting for. If you want to post
some reliable code that does this, I'd appreciate it.
Danny
# %< -----------------------------------------------------
from matplotlib.matlab import *
import Numeric as N
def doPlots1(const,color,legendList=[],legendTextList=[]):
	y1=N.arange(0., 10, 1)+ const
	x = arange(len(y1))
	
	ln1 = plot(x,y1,color+'+-')
	legendList.append(ln1)
	legendTextList.append('line1')
	
	y2 = y1 + 1
	ln2 = plot(x,y2,color+'^-')
	legendList.append(ln2)
	legendTextList.append('line2')
	legend(legendList,legendTextList)
	show()
	
def doPlots2(const,color):
	legendList=[]
	legendTextList=[]	
	
	y1=N.arange(0., 10, 1)+ const
	x = arange(len(y1))
	
	ln1 = plot(x,y1,color+'+-')
	legendList.append(ln1)
	legendTextList.append('line1')
	
	y2 = y1 + 1
	ln2 = plot(x,y2,color+'^-')
	legendList.append(ln2)
	legendTextList.append('line2')
	legend(legendList,legendTextList)
	show()
figure(1)	
doPlots1(0,'r')
doPlots1(5,'b')
figure(2)	
doPlots2(0,'r')
doPlots2(5,'b')
		
__________________________________
Do you Yahoo!?
Read only the mail you want - Yahoo! Mail SpamGuard.
http://promotions.yahoo.com/new_mail 
From: Darren D. <dd...@co...> - 2004年07月06日 03:53:58
Attachments: dd55.vcf
Hello,
Just wanted to report an error message.
file "...\dynamic_demo_wx.py" line 109, in onTimer
 self.lines[0].setdata(self.ind,self.X[:,self.count])
IndexError: Index out of range
I am running WinXP, Matplotlib 0.54.2, wx 2.4.2.4, and started the 
example from windows explorer. This error message repeats for some time, 
then the example will run for a while, then the error message again, 
back and forth.
-- 
Darren S. Dale
dd...@co...
PGP public key available

Showing 5 results of 5

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