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



Showing 4 results of 4

From: Alan I. <ai...@am...> - 2006年05月31日 17:41:10
On 2006年5月31日, Louis Pecora wrote: 
> Is this good matplotlib behavior?
I think so. It is Python behavior.
You are using a mutable object,
and the plot of this object changes
when you chage the object.
> Is it necessary to use new variables for each call of 
> plot? 
No. Just assign a new object to the name,
rather than changing the existing object.
hth,
Alan Isaac
From: Louis P. <pe...@an...> - 2006年05月31日 17:28:20
I have some simple code (I've cut it down a lot, but kept the problem) 
that tries to plot two sets of data using the same variables. It 
appears that re-using the variables from the first plot for the second 
plot affects the first plot. In fact the two plots become identical. I 
am guessing that the variables used in the 1st plot are pointed to by 
other matplotlib internal variables (but not plotted until Show() is 
called -- a guess on my part). In Python fashion when I change a 
variable in preparation for the 2nd plot, the values in the 1st plot 
change, too.
Here is sample code based on some code sent to me by Jeremy O'Donoghue 
as an example of how to embed matplotlib in wxPython. The problem is in 
the method plot_data in the PlotFigure class. Note how x and y are 
reused for the 2nd plot. The output should be an 'X' shape, but only 
one line shows up, the 2nd plot line. If you add new variables to do 
the 2nd plot (e.g. u=zeroes((2,),Float), v=zeroes((2,),Float)) and 
replace the x and y in the 2nd plot with those variables, then it works 
correctly.
Is this good matplotlib behavior? Is it necessary to use new variables 
for each call of plot?
I am using wxPython wx-2.6-mac-unicode, matplotlib 0.82, Python 2.4, 
on a Macintosh Powerbook G4, OS X 10.4
--------------------------------- The code (self contained as run from 
BBEdit through the Terminal):
#!/usr/local/bin/pythonw
from Numeric import *
import matplotlib
matplotlib.use('WX')
from matplotlib.backends.backend_wx import Toolbar, FigureCanvasWx,\
 FigureManager
from matplotlib.figure import Figure
from matplotlib.axes import Subplot
import matplotlib.numerix as numpy
import wx
 
class PlotFigure(wx.Frame):
 def __init__(self):
 wx.Frame.__init__(self, None, -1, "Test embedded wx.Figure")
 self.fig = Figure((10,8), 75)
 self.canvas = FigureCanvasWx(self, -1, self.fig)
 self.toolbar = Toolbar(self.canvas)
 self.toolbar.Realize()
 # On Windows, default frame size behaviour is incorrect
 # you don't need this under Linux
 tw, th = self.toolbar.GetSizeTuple()
 fw, fh = self.canvas.GetSizeTuple()
 self.toolbar.SetSize(wx.Size(fw, th))
 # Create a figure manager to manage things
 self.figmgr = FigureManager(self.canvas, 1, self)
 # Now put all into a sizer
 sizer = wx.BoxSizer(wx.VERTICAL)
 # This way of adding to sizer allows resizing
 sizer.Add(self.canvas, 1, wx.LEFT|wx.TOP|wx.GROW)
 # Best to allow the toolbar to resize!
 sizer.Add(self.toolbar, 0, wx.GROW)
 self.SetSizer(sizer)
 self.Fit()
 # *** HERE'S THE PROBLEM PART ***
 def plot_data(self):
 # Use ths line if using a toolbar
 a = self.fig.add_subplot(111)
 
 # Or this one if there is no toolbar
 #a = Subplot(self.fig, 111)
 x=zeros((2,),Float)
 y=zeros((2,),Float)
 
 # 1st Plot .................
 x[0]= 1.0
 y[0]= 1.0
 x[1]=-1.0
 y[1]=-1.0
 a.plot(x,y)
 # 2nd Plot .................
 x[0]=-1.0
 y[0]= 1.0
 x[1]= 1.0
 y[1]=-1.0
 a.plot(x,y)
 
 self.toolbar.update()
 def GetToolBar(self):
 # You will need to override GetToolBar if you are using an
 # unmanaged toolbar in your frame
 return self.toolbar
 
if __name__ == '__main__':
 # Plot
 app = wx.PySimpleApp(0)
 frame = PlotFigure()
 frame.plot_data()
 frame.Show()
 app.MainLoop()
-- 
Cheers,
Lou Pecora
Code 6362
Naval Research Lab
Washington, DC 20375
USA
Ph: +202-767-6002
email: pe...@an...
From: leau2001 <lea...@fr...> - 2006年05月31日 09:17:00
Hi, i try to use the plot_date function and i have some problems, is 
anybody can help me
My program :
First to show it's ok to run if i just used the only plot function
> from pylab import *
> import marshal
> import time
> import string
>
> lst_date=[]
> points=[]
> belos=[['2', '2', '2', '2', '2', '2', '2', '54', '125', '169', '224', 
> '245', '245', '245', '325', '325', '325', '453', '486', '521', '521', 
> '521', '8596', '9566', '9848', '10064'], [1148378715.6400001, 
> 1148379045.312, 1148379057.7179999, 1148379069.375, 1148379331.921, 
> 1148390222.3280001, 1148390265.2650001, 1148396382.562, 
> 1148464116.609, 1148481671.6559999, 1148534908.2520001, 
> 1148551483.8299999, 1148573370.8770001, 1148589279.517, 
> 1148625453.8429999, 1148640384.5150001, 1148659451.25, 1148709552.921, 
> 1148740419.375, 1148799935.5780001, 1148827804.0, 1148886086.109, 
> 1148915795.984, 1148972914.8429999, 1149001049.671, 
> 1149053926.7650001], ['2:349:7', '2:349:7', '2:349:7', '2:349:7', 
> '2:349:7', '2:349:7', '2:349:7', '3:56:5', '3:56:5', '3:56:5', '3:56:5']]
>
> point=belos[0]
> dt_date=belos[1]
>
>
> for j in dt_date:
> date=time.ctime(j)
> lst_date.append(date)
>
> print lst_date
>
>
> for i in point:
> a=int(i)
> points.append(a)
> 
> print belos
> print point
> print len(point)
> print len(lst_date)
> #plot (date, point, 'ro')
> #show()
>
> #plot_date(dt_date, points, '', xdate=True, ydate=False)
> plot(dt_date, points, '',)
> #savefig('secondfig.png')
> show()
The i try with the plot_date function and i got on error:
> Traceback (most recent call last):
> File "C:\Python24\uni_22\belos_stat.py", line 32, in -toplevel-
> plot_date(dt_date, points, '', xdate=True, ydate=False)
> File "C:\Python24\Lib\site-packages\matplotlib\pylab.py", line 2039, 
> in plot_date
> ret = gca().plot_date(*args, **kwargs)
> File "C:\Python24\Lib\site-packages\matplotlib\axes.py", line 2830, 
> in plot_date
> self.autoscale_view()
> File "C:\Python24\Lib\site-packages\matplotlib\axes.py", line 815, 
> in autoscale_view
> self.set_xlim(locator.autoscale())
> File "C:\Python24\Lib\site-packages\matplotlib\dates.py", line 537, 
> in autoscale
> dmin, dmax = self.datalim_to_dt()
> File "C:\Python24\Lib\site-packages\matplotlib\dates.py", line 403, 
> in datalim_to_dt
> return num2date(dmin, self.tz), num2date(dmax, self.tz)
> File "C:\Python24\Lib\site-packages\matplotlib\dates.py", line 205, 
> in num2date
> if not iterable(x): return _from_ordinalf(x, tz)
> File "C:\Python24\Lib\site-packages\matplotlib\dates.py", line 154, 
> in _from_ordinalf
> dt = datetime.datetime.fromordinal(ix)
> ValueError: year is out of range
i want the x axis show me the date on this format : Tue May 23 12:05:15 
2006', 'Tue May 23 12:10:45 2006', 'Tue May 23 12:10:57 2006 etc...
Thx for answer
From: <dd...@ja...> - 2006年05月31日 02:10:46
On Friday 26 May 2006 11:08 am, Michael McNeil Forbes wrote:
> I am having some problems with the axes frame being clipped.
>
>
> Consider the following:
>
> from pylab import *
> fill([0,1,1,0],[0,0,1,1],facecolor=(1,1,1),edgecolor=(1,1,1))
> axis([-1,1,-1,1])
> gca().get_frame().set_linewidth(20)
> show()
I've had the same problem as you. My crude hack was to slightly extend the 
xlim and ylim as in
 xlim(xmin-xclip, xmax+xclip)
 ylim(ymin-yclip, ymax+yclip)
where xclip and yclip are small values (about 0.5% of the x and y ranges).

Showing 4 results of 4

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