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



Showing results of 110

1 2 3 .. 5 > >> (Page 1 of 5)
From: Gerhard V. <s.v...@nt...> - 2004年06月30日 14:47:16
To answer my own question - I commented out line 790 in font_manager.py:
#pickle.dump(self.ttfdict, file(ttfcache, 'w'))
This fixed it for me
Gerhard
Gerhard Venter wrote:
> 790, in __init__
> pickle.dump(self.ttfdict, file(ttfcache, 'w'))
> IOError: [Errno 2] No such file or directory: 
> '%USERPROFILE%\\.ttffont.cache'
From: Gerhard V. <s.v...@nt...> - 2004年06月30日 13:44:10
Hi
I have just installed matplotlib and Python 2.3.3 for Windows (Enthought 
Edition) on Win XP. Then I ran the sample at:
http://matplotlib.sourceforge.net/screenshots/simple_plot.py. It caused 
the traceback below, related to the ttfcache
I have tried:
1. Created a System Environment variable called ttfcache that points to 
C:\Documents and Settings\gventer\Local Settings\Application Data
(which is where the Windows font cache file IconCache.db is)
2. Created a folder in %USERPROFILE%\\.ttffont.cache - (that is 
C:\Documents and Settings\gventer\.ttffont.cache)
Every time I still get:
Traceback (most recent call last):
 File "C:\myscripts\simple_plot.py", line 1, in ?
 from matplotlib.matlab import *
 File "C:\PYTHON23\Lib\site-packages\matplotlib\matlab.py", line 133, in ?
 from axes import Axes
 File "C:\PYTHON23\Lib\site-packages\matplotlib\axes.py", line 10, in ?
 from axis import XTick, YTick, XAxis, YAxis
 File "C:\PYTHON23\Lib\site-packages\matplotlib\axis.py", line 20, in ?
 from font_manager import FontProperties
 File "C:\PYTHON23\Lib\site-packages\matplotlib\font_manager.py", line 
944, in ?
 fontManager = FontManager()
 File "C:\PYTHON23\Lib\site-packages\matplotlib\font_manager.py", line 
790, in __init__
 pickle.dump(self.ttfdict, file(ttfcache, 'w'))
IOError: [Errno 2] No such file or directory: 
'%USERPROFILE%\\.ttffont.cache'
What else could I try?
Thanks
Gerhard
From: Schalkwyk, J. <Joh...@sc...> - 2004年06月29日 15:26:38
Some more info. I'm running a 1.8Ghz PIV laptop with windows XP
professional. Not sure if speed of machine has anything todo with it. The
repaints cause flicker on the window, and then after a while the messages
appear.
-----Original Message-----
From: Schalkwyk, Johan 
Sent: Tuesday, June 29, 2004 11:25 AM
To: 'John Hunter'; Schalkwyk, Johan
Cc: mat...@li...
Subject: RE: [Matplotlib-users] Assertion triggered in wxMemory DC
With the attached example code you sent me I get the following messages
after some time. It seems to be caught in some form of endless loop, just
scrolling the messages over and over.
Also thank you for the example. I can simply my app code much more now.
Where can I find the src distribution. I probably did not look properly on
the web site.
Johan
line 570, in new_gc
 self.gc = GraphicsContextWx(self.bitmap, self)
 File
"c:\Tools\Python23\lib\site-packages\matplotlib\backends\backend_wx.py",
line 682, in __init__
 self.SelectObject(bitmap)
 File "C:\Tools\Python23\Lib\site-packages\wx\gdi.py", line 3017, in
SelectObje
ct
 return _gdi.MemoryDC_SelectObject(*args, **kwargs)
wx.core.PyAssertionError: C++ assertion "wxAssertFailure" failed in
..\..\src\ms
w\dcmemory.cpp(133): Couldn't select a bitmap into wxMemoryDC
Traceback (most recent call last):
 File "mattest2.py", line 42, in OnPaint
 self.canvas.draw()
 File
"c:\Tools\Python23\lib\site-packages\matplotlib\backends\backend_wx.py",
line 921, in draw
 self.figure.draw(self.renderer)
 File "c:\Tools\Python23\lib\site-packages\matplotlib\figure.py", line 132,
in
draw
 if self.frameon: self._figurePatch.draw(renderer)
 File "C:\Tools\Python23\Lib\site-packages\matplotlib\patches.py", line 54,
in
draw
 gc = renderer.new_gc()
 File
"c:\Tools\Python23\lib\site-packages\matplotlib\backends\backend_wx.py",
line 570, in new_gc
-----Original Message-----
From: John Hunter [mailto:jdh...@ac...] 
Sent: Tuesday, June 29, 2004 10:47 AM
To: Schalkwyk, Johan
Cc: mat...@li...
Subject: Re: [Matplotlib-users] Assertion triggered in wxMemory DC
>>>>> "Schalkwyk," == Schalkwyk, Johan <Joh...@sc...>
writes:
 Schalkwyk,> Thank you for the help I removed the show() command
 Schalkwyk,> from the loop. Now just calling grid(True) multiple
 Schalkwyk,> times. On my machine I narrowed the loop to 57 and it
 Schalkwyk,> started happening. At 50 it did not.
Perhaps I didn't make myself clear. The way you are using matplotlib
does not make sense. matplotlib has two modes: a "matlab interface"
and an embedded interface. You should not embed the matlab interface
directly into a GUI. The matlab interface does a lot of stuff under
the hood, like creating and managing figures and figure windows,
managing redraws, etc. When you create your own figure window outside
this framework, and then try to use the framework, the result is
undefined. If you are using matplotlib in a GUI, *do not import
matplotlib.matlab*. You need to follow the example of
embedding_in_wx2.py.
Below is your example translated to the GUI interface - on my system,
calling grid until the sun sets presents no problems, and it really
couldn't because all it does is set a boolean. In the matlab
interface, if you have interactive: True in your rc file, calling grid
does a lot more, including repainting the figure. Try running this
example, shaking it, resizing it, etc... and see if you can crash it;
I was unable to cause any problems.
If you have trouble, please let me know, but also consider trying
replacing wx for wxagg, which uses antigrain for drawing and is
probably more stable than wx, which does occasionally show dc related
errors.
By the way, there was an error in your legend code
You had
 legend('line', blahblah)
and you need
 legend( ('line',), blahblah)
That is, legend expects a list or tuple of strings, not a string.
 Schalkwyk,> By the way Kudos for matplotlib. Amazing. I had to dig
 Schalkwyk,> around the code and news groups to figure out how to
 Schalkwyk,> find the user coordinates of a mouse click. Reading
 Schalkwyk,> the code opens your eyes the wonderful design that is
 Schalkwyk,> backend dependent.
Thanks. Do you have the src distribution? There is an example in the
examples directory examples/coords_demo.py (works with Tk, GTK and WX)
that shows you how to get the mouse click coordinates. The examples
dir is your first line of defense when you want to figure out
something new. Unfortunately, I forgot to upload the zip file with
the 0.54.2 release, so look here
 http://matplotlib.sf.net/examples
Here's the example:
#!/usr/bin/env python
"""
An example of how to use wx or wxagg in an application w/o the toolbar
"""
from matplotlib.numerix import arange, sin, pi
import matplotlib
matplotlib.use('WX')
from matplotlib.backends.backend_wx import FigureCanvasWx as FigureCanvas
from matplotlib.figure import Figure
from wxPython.wx import *
class CanvasFrame(wxFrame):
 
 def __init__(self):
 wxFrame.__init__(self,None,-1,
 'CanvasFrame',size=(550,350))
 self.SetBackgroundColour(wxNamedColor("WHITE"))
 self.figure = Figure(figsize=(5,4), dpi=100)
 self.ax = self.figure.add_subplot(111)
 t = arange(0.0, 2.0, 0.01)
 s = sin(2*pi*t)
 l = self.ax.plot(t, s, linewidth=1.0)
 self.ax.set_xlabel('time (s)')
 self.ax.set_ylabel('voltage (mV)')
 self.ax.set_title('About as simple as it gets, folks')
 self.ax.legend(('line',), loc='upper right')
 for i in range(100):
 self.ax.grid(True)
 self.canvas = FigureCanvas(self, -1, self.figure)
 self.sizer = wxBoxSizer(wxVERTICAL)
 self.sizer.Add(self.canvas, 1, wxTOP | wxLEFT | wxEXPAND)
 # Capture the paint message 
 EVT_PAINT(self, self.OnPaint) 
 def OnPaint(self, event):
 self.canvas.draw()
 
class App(wxApp):
 
 def OnInit(self):
 'Create the main window and insert the custom frame'
 frame = CanvasFrame()
 frame.Show(true)
 return true
app = App(0)
app.MainLoop()
From: Schalkwyk, J. <Joh...@sc...> - 2004年06月29日 15:26:14
With the attached example code you sent me I get the following messages
after some time. It seems to be caught in some form of endless loop, just
scrolling the messages over and over.
Also thank you for the example. I can simply my app code much more now.
Where can I find the src distribution. I probably did not look properly on
the web site.
Johan
line 570, in new_gc
 self.gc = GraphicsContextWx(self.bitmap, self)
 File
"c:\Tools\Python23\lib\site-packages\matplotlib\backends\backend_wx.py",
line 682, in __init__
 self.SelectObject(bitmap)
 File "C:\Tools\Python23\Lib\site-packages\wx\gdi.py", line 3017, in
SelectObje
ct
 return _gdi.MemoryDC_SelectObject(*args, **kwargs)
wx.core.PyAssertionError: C++ assertion "wxAssertFailure" failed in
..\..\src\ms
w\dcmemory.cpp(133): Couldn't select a bitmap into wxMemoryDC
Traceback (most recent call last):
 File "mattest2.py", line 42, in OnPaint
 self.canvas.draw()
 File
"c:\Tools\Python23\lib\site-packages\matplotlib\backends\backend_wx.py",
line 921, in draw
 self.figure.draw(self.renderer)
 File "c:\Tools\Python23\lib\site-packages\matplotlib\figure.py", line 132,
in
draw
 if self.frameon: self._figurePatch.draw(renderer)
 File "C:\Tools\Python23\Lib\site-packages\matplotlib\patches.py", line 54,
in
draw
 gc = renderer.new_gc()
 File
"c:\Tools\Python23\lib\site-packages\matplotlib\backends\backend_wx.py",
line 570, in new_gc
-----Original Message-----
From: John Hunter [mailto:jdh...@ac...] 
Sent: Tuesday, June 29, 2004 10:47 AM
To: Schalkwyk, Johan
Cc: mat...@li...
Subject: Re: [Matplotlib-users] Assertion triggered in wxMemory DC
>>>>> "Schalkwyk," == Schalkwyk, Johan <Joh...@sc...>
writes:
 Schalkwyk,> Thank you for the help I removed the show() command
 Schalkwyk,> from the loop. Now just calling grid(True) multiple
 Schalkwyk,> times. On my machine I narrowed the loop to 57 and it
 Schalkwyk,> started happening. At 50 it did not.
Perhaps I didn't make myself clear. The way you are using matplotlib
does not make sense. matplotlib has two modes: a "matlab interface"
and an embedded interface. You should not embed the matlab interface
directly into a GUI. The matlab interface does a lot of stuff under
the hood, like creating and managing figures and figure windows,
managing redraws, etc. When you create your own figure window outside
this framework, and then try to use the framework, the result is
undefined. If you are using matplotlib in a GUI, *do not import
matplotlib.matlab*. You need to follow the example of
embedding_in_wx2.py.
Below is your example translated to the GUI interface - on my system,
calling grid until the sun sets presents no problems, and it really
couldn't because all it does is set a boolean. In the matlab
interface, if you have interactive: True in your rc file, calling grid
does a lot more, including repainting the figure. Try running this
example, shaking it, resizing it, etc... and see if you can crash it;
I was unable to cause any problems.
If you have trouble, please let me know, but also consider trying
replacing wx for wxagg, which uses antigrain for drawing and is
probably more stable than wx, which does occasionally show dc related
errors.
By the way, there was an error in your legend code
You had
 legend('line', blahblah)
and you need
 legend( ('line',), blahblah)
That is, legend expects a list or tuple of strings, not a string.
 Schalkwyk,> By the way Kudos for matplotlib. Amazing. I had to dig
 Schalkwyk,> around the code and news groups to figure out how to
 Schalkwyk,> find the user coordinates of a mouse click. Reading
 Schalkwyk,> the code opens your eyes the wonderful design that is
 Schalkwyk,> backend dependent.
Thanks. Do you have the src distribution? There is an example in the
examples directory examples/coords_demo.py (works with Tk, GTK and WX)
that shows you how to get the mouse click coordinates. The examples
dir is your first line of defense when you want to figure out
something new. Unfortunately, I forgot to upload the zip file with
the 0.54.2 release, so look here
 http://matplotlib.sf.net/examples
Here's the example:
#!/usr/bin/env python
"""
An example of how to use wx or wxagg in an application w/o the toolbar
"""
from matplotlib.numerix import arange, sin, pi
import matplotlib
matplotlib.use('WX')
from matplotlib.backends.backend_wx import FigureCanvasWx as FigureCanvas
from matplotlib.figure import Figure
from wxPython.wx import *
class CanvasFrame(wxFrame):
 
 def __init__(self):
 wxFrame.__init__(self,None,-1,
 'CanvasFrame',size=(550,350))
 self.SetBackgroundColour(wxNamedColor("WHITE"))
 self.figure = Figure(figsize=(5,4), dpi=100)
 self.ax = self.figure.add_subplot(111)
 t = arange(0.0, 2.0, 0.01)
 s = sin(2*pi*t)
 l = self.ax.plot(t, s, linewidth=1.0)
 self.ax.set_xlabel('time (s)')
 self.ax.set_ylabel('voltage (mV)')
 self.ax.set_title('About as simple as it gets, folks')
 self.ax.legend(('line',), loc='upper right')
 for i in range(100):
 self.ax.grid(True)
 self.canvas = FigureCanvas(self, -1, self.figure)
 self.sizer = wxBoxSizer(wxVERTICAL)
 self.sizer.Add(self.canvas, 1, wxTOP | wxLEFT | wxEXPAND)
 # Capture the paint message 
 EVT_PAINT(self, self.OnPaint) 
 def OnPaint(self, event):
 self.canvas.draw()
 
class App(wxApp):
 
 def OnInit(self):
 'Create the main window and insert the custom frame'
 frame = CanvasFrame()
 frame.Show(true)
 return true
app = App(0)
app.MainLoop()
From: Schalkwyk, J. <Joh...@sc...> - 2004年06月29日 15:20:27
The example I created was the smallest sample code I could make to reproduce
the problem. 
The code below is more true to my application. It does not use the matlab
interface. It does however mimick the matlab interface. I did not have the
src distribution so I created this from reading the code. Note the main
frame calls the draw command on the canvas (MatlabFigure) 100 times. This
triggers the problem as well.
I'll take a look at the source distribution.
Thank you for the help
Johan
import wx
import matplotlib
import numarray
matplotlib.use('WX')
from matplotlib.figure import Figure
from matplotlib.backends.backend_wx import FigureCanvasWx
from matplotlib.backend_bases import FigureManagerBase, error_msg
from matplotlib.axes import Axes
from matplotlib.cbook import flatten, is_string_like, exception_to_str
import matplotlib.mlab as mlab
#---------------------------------------------------------------------------
class MatlabFigure(FigureCanvasWx):
 def __init__(self, parent):
 self.fig = Figure()
 FigureCanvasWx.__init__(self, parent, -1, self.fig)
 
 self.figmgr = FigureManagerBase(self, 0)
 self.gca = self.figmgr.get_current_axis()
 # end def
 def GetXY(self, event):
 screenPos= numarray.array( event.GetPosition())
 ymin, height = self.fig.bbox.intervaly().get_bounds()
 x, y = screenPos[0], height-screenPos[1]
 if self.gca.in_axes(x, y):
 xy = self.gca.transData.inverse_xy_tup((x, y))
 return xy
 else:
 return None
 # end if
 # end def
 
 def axis(self, *v):
 if len(v)==1 and is_string_like(v[0]):
 s = v[0]
 if s.lower()=='on': self.gca.set_axis_on()
 elif s.lower()=='off': self.gca.set_axis_off()
 else:
 error_msg('Unrecognized string %s to axis; try on or off' %
s)
 return
 # end if
 
 try: v[0]
 except IndexError:
 xlim = self.gca.get_xlim()
 ylim = self.gca.get_ylim()
 return [xlim[0], xlim[1], ylim[0], ylim[1]]
 # end except
 
 v = v[0]
 if len(v) != 4:
 error_msg('v must contain [xmin xmax ymin ymax]')
 return
 # end if
 self.gca.set_xlim([v[0], v[1]])
 self.gca.set_ylim([v[2], v[3]])
 # end def
 def axes(self, *args, **kwargs):
 nargs = len(args)
 if len(args)==0: return subplot(111, **kwargs)
 if nargs>1:
 error_msg('Only one non keyword arg to axes allowed')
 return
 # end if
 
 arg = args[0]
 if isinstance(arg, Axes):
 self.figmgr.set_current_axes(arg)
 ret = arg
 else:
 rect = arg
 ret = self.figmgr.add_axes(rect, **kwargs)
 # end if
 return ret
 # end def
 def bar(self, *args, **kwargs):
 try: patches = self.gca.bar(*args, **kwargs)
 except Exception, msg:
 s = exception_to_str(msg)
 error_msg(s)
 raise RuntimeError(msg)
 # end except
 return patches
 # end def
 def cla(self):
 self.gca.cla()
 # end def
 def clf(self):
 self.figmgr.clf()
 # end def
 def errorbar(self, x, y, yerr=None, xerr=None, fmt='b-', ecolor='k',
capsize=3):
 try: ret = self.gca.errorbar(x, y, yerr, xerr, fmt, ecolor,
capsize)
 except ValueError, msg:
 msg = raise_msg_to_str(msg)
 error_msg(msg)
 else:
 return ret
 # end try
 # end def
 def figlegend(self, handles, labels, loc):
 l = self.legend(handles, labels, loc)
 return l
 # end def
 def fill(self, *args, **kwargs):
 try: patch = self.gca.fill(*args, **kwargs)
 except Exception, msg:
 s = exception_to_str(msg)
 error_msg(s)
 raise RuntimeError('Could not exectute fill')
 # end except
 return patch
 # end def
 def grid(self, b):
 self.gca.grid(b)
 # end def
 def hist(self, x, bins=10, noplot=0, normed=0, bottom=0):
 if noplot: return mlab.hist(x, bins, normed)
 else:
 try:
 ret = self.gca.hist(x, bins, normed, bottom)
 except ValueError, msg:
 msg = raise_msg_to_str(msg)
 error_msg(msg)
 raise RuntimeError, msg
 return ret
 # end if
 # end def
 def legend(self, *args, **kwargs):
 ret = self.gca.legend(*args, **kwargs)
 return ret
 # end def
 
 def plot(self, *args, **kwargs):
 try: lines = self.gca.plot(*args, **kwargs)
 except ValueError, msg:
 msg = raise_msg_to_str(msg)
 error_msg(msg)
 return lines
 # end def
 def savefig(self, *args, **kwargs):
 for key in ('dpi', 'facecolor', 'edgecolor'):
 if not kwargs.has_key(key):
 kwargs[key] = rcParams['savefig.%s'%key]
 self.print_figure(*args, **kwargs)
 # end def
 def scatter(self, *args, **kwargs):
 try: patches = self.gca.scatter(*args, **kwargs)
 except ValueError, msg:
 msg = raise_msg_to_str(msg)
 error_msg(msg)
 raise RuntimeError, msg
 return patches
 # end def
 def scatter_classic(self, *args, **kwargs):
 try: patches = self.gca.scatter_classic(*args, **kwargs)
 except ValueError, msg:
 msg = raise_msg_to_str(msg)
 error_msg(msg)
 raise RuntimeError, msg
 return patches
 # end def
 def stem(self, *args, **kwargs):
 try: ret = self.gca.stem(*args, **kwargs)
 except ValueError, msg:
 msg = raise_msg_to_str(msg)
 error_msg(msg)
 else:
 return ret
 # end def
 def subplot(self, *args, **kwargs):
 try:
 self.figmgr.add_subplot(*args, **kwargs)
 self.gca = self.figmgr.get_current_axis()
 except ValueError, msg:
 msg = raise_msg_to_str(msg)
 error_msg(msg)
 raise RuntimeError, msg
 return self.gca
 # end def
 def text(self, x, y, label, fontdict=None, **kwargs):
 t = self.gca.text(x, y, label, fontdict, **kwargs)
 return t
 # end def
 def title(self, s, *args, **kwargs):
 l = self.gca.set_title(s, *args, **kwargs)
 return l
 # end def
 def vlines(self, *args, **kwargs): 
 try: lines = self.gca.vlines(*args, **kwargs)
 except ValueError, msg:
 msg = raise_msg_to_str(msg)
 error_msg(msg)
 raise RuntimeError, msg
 return lines
 # end def
 def xlabel(self, s, *args, **kwargs):
 l = self.gca.set_xlabel(s, *args, **kwargs)
 return l
 # end def
 def ylabel(self, s, *args, **kwargs):
 l = self.gca.set_ylabel(s, *args, **kwargs)
 return l
 # end def
 
#---------------------------------------------------------------------------
# class MatFrame(wx.MDIChildFrame):
class MatFrame(wx.Frame):
 
 def __init__(self, parent):
 #wx.MDIChildFrame.__init__(self, parent, -1, "Matlab WX interface",
 # size=(600,600))
 wx.Frame.__init__(self, None, -1, "Matlab WX interface",
 size=(600,600))
 self.figure = figure = MatlabFigure(self)
 # histg = figure.hist([1,2,3,4,5,6,7,7,8,9,1,23,4,5,5,6])
 histg = figure.bar([1,2,3,4], [10,15, 7, 3], width=1)
 line1 = figure.plot([1,2,3,4], [2,3,6,7], 'b-')
 line2 = figure.plot([0,10,20], [0,10,20], 'g')
 figure.axis([0,30,0,20])
 
 figure.grid(1)
 figure.xlabel('Confidence', {'fontsize': 'small'})
 figure.ylabel('Count', {'fontsize': 'small'})
 figure.legend((line1, line2, histg),
 ('line1', 'line2', 'histg'),
 'upper right')
 figure.title('Confidence Histogram')
 
 figure.Bind(wx.EVT_LEFT_DOWN, self.OnSelectBucket)
 # end def
 
 def OnSelectBucket(self, event):
 xy = self.figure.GetXY(event)
 print xy
 # end def
#---------------------------------------------------------------------------
class MatlabMDI(wx.MDIParentFrame):
 def __init__(self):
 wx.MDIParentFrame.__init__(self, None, -1, "Matlab
MDI",size=(900,700))
 MatFrame(self)
 self.Show()
 # end def
class App(wx.App):
 """Application class."""
 def OnInit(self):
 #MatlabMDI()
 frame = MatFrame(self)
 frame.Show()
 for i in range(100):
 frame.figure.draw()
 # end for
 
 #self.xframe = MatFrame()
 #self.xframe.Show()
 #self.xframe.grid(0)
 return True
 # end def
#---------------------------------------------------------------------------
if __name__ == '__main__':
 app = App()
 app.MainLoop()
 
-----Original Message-----
From: John Hunter [mailto:jdh...@ac...] 
Sent: Tuesday, June 29, 2004 10:47 AM
To: Schalkwyk, Johan
Cc: mat...@li...
Subject: Re: [Matplotlib-users] Assertion triggered in wxMemory DC
>>>>> "Schalkwyk," == Schalkwyk, Johan <Joh...@sc...>
writes:
 Schalkwyk,> Thank you for the help I removed the show() command
 Schalkwyk,> from the loop. Now just calling grid(True) multiple
 Schalkwyk,> times. On my machine I narrowed the loop to 57 and it
 Schalkwyk,> started happening. At 50 it did not.
Perhaps I didn't make myself clear. The way you are using matplotlib
does not make sense. matplotlib has two modes: a "matlab interface"
and an embedded interface. You should not embed the matlab interface
directly into a GUI. The matlab interface does a lot of stuff under
the hood, like creating and managing figures and figure windows,
managing redraws, etc. When you create your own figure window outside
this framework, and then try to use the framework, the result is
undefined. If you are using matplotlib in a GUI, *do not import
matplotlib.matlab*. You need to follow the example of
embedding_in_wx2.py.
Below is your example translated to the GUI interface - on my system,
calling grid until the sun sets presents no problems, and it really
couldn't because all it does is set a boolean. In the matlab
interface, if you have interactive: True in your rc file, calling grid
does a lot more, including repainting the figure. Try running this
example, shaking it, resizing it, etc... and see if you can crash it;
I was unable to cause any problems.
If you have trouble, please let me know, but also consider trying
replacing wx for wxagg, which uses antigrain for drawing and is
probably more stable than wx, which does occasionally show dc related
errors.
By the way, there was an error in your legend code
You had
 legend('line', blahblah)
and you need
 legend( ('line',), blahblah)
That is, legend expects a list or tuple of strings, not a string.
 Schalkwyk,> By the way Kudos for matplotlib. Amazing. I had to dig
 Schalkwyk,> around the code and news groups to figure out how to
 Schalkwyk,> find the user coordinates of a mouse click. Reading
 Schalkwyk,> the code opens your eyes the wonderful design that is
 Schalkwyk,> backend dependent.
Thanks. Do you have the src distribution? There is an example in the
examples directory examples/coords_demo.py (works with Tk, GTK and WX)
that shows you how to get the mouse click coordinates. The examples
dir is your first line of defense when you want to figure out
something new. Unfortunately, I forgot to upload the zip file with
the 0.54.2 release, so look here
 http://matplotlib.sf.net/examples
Here's the example:
#!/usr/bin/env python
"""
An example of how to use wx or wxagg in an application w/o the toolbar
"""
from matplotlib.numerix import arange, sin, pi
import matplotlib
matplotlib.use('WX')
from matplotlib.backends.backend_wx import FigureCanvasWx as FigureCanvas
from matplotlib.figure import Figure
from wxPython.wx import *
class CanvasFrame(wxFrame):
 
 def __init__(self):
 wxFrame.__init__(self,None,-1,
 'CanvasFrame',size=(550,350))
 self.SetBackgroundColour(wxNamedColor("WHITE"))
 self.figure = Figure(figsize=(5,4), dpi=100)
 self.ax = self.figure.add_subplot(111)
 t = arange(0.0, 2.0, 0.01)
 s = sin(2*pi*t)
 l = self.ax.plot(t, s, linewidth=1.0)
 self.ax.set_xlabel('time (s)')
 self.ax.set_ylabel('voltage (mV)')
 self.ax.set_title('About as simple as it gets, folks')
 self.ax.legend(('line',), loc='upper right')
 for i in range(100):
 self.ax.grid(True)
 self.canvas = FigureCanvas(self, -1, self.figure)
 self.sizer = wxBoxSizer(wxVERTICAL)
 self.sizer.Add(self.canvas, 1, wxTOP | wxLEFT | wxEXPAND)
 # Capture the paint message 
 EVT_PAINT(self, self.OnPaint) 
 def OnPaint(self, event):
 self.canvas.draw()
 
class App(wxApp):
 
 def OnInit(self):
 'Create the main window and insert the custom frame'
 frame = CanvasFrame()
 frame.Show(true)
 return true
app = App(0)
app.MainLoop()
From: John H. <jdh...@ac...> - 2004年06月29日 15:10:57
>>>>> "Schalkwyk," == Schalkwyk, Johan <Joh...@sc...> writes:
 Schalkwyk,> Thank you for the help I removed the show() command
 Schalkwyk,> from the loop. Now just calling grid(True) multiple
 Schalkwyk,> times. On my machine I narrowed the loop to 57 and it
 Schalkwyk,> started happening. At 50 it did not.
Perhaps I didn't make myself clear. The way you are using matplotlib
does not make sense. matplotlib has two modes: a "matlab interface"
and an embedded interface. You should not embed the matlab interface
directly into a GUI. The matlab interface does a lot of stuff under
the hood, like creating and managing figures and figure windows,
managing redraws, etc. When you create your own figure window outside
this framework, and then try to use the framework, the result is
undefined. If you are using matplotlib in a GUI, *do not import
matplotlib.matlab*. You need to follow the example of
embedding_in_wx2.py.
Below is your example translated to the GUI interface - on my system,
calling grid until the sun sets presents no problems, and it really
couldn't because all it does is set a boolean. In the matlab
interface, if you have interactive: True in your rc file, calling grid
does a lot more, including repainting the figure. Try running this
example, shaking it, resizing it, etc... and see if you can crash it;
I was unable to cause any problems.
If you have trouble, please let me know, but also consider trying
replacing wx for wxagg, which uses antigrain for drawing and is
probably more stable than wx, which does occasionally show dc related
errors.
By the way, there was an error in your legend code
You had
 legend('line', blahblah)
and you need
 legend( ('line',), blahblah)
That is, legend expects a list or tuple of strings, not a string.
 Schalkwyk,> By the way Kudos for matplotlib. Amazing. I had to dig
 Schalkwyk,> around the code and news groups to figure out how to
 Schalkwyk,> find the user coordinates of a mouse click. Reading
 Schalkwyk,> the code opens your eyes the wonderful design that is
 Schalkwyk,> backend dependent.
Thanks. Do you have the src distribution? There is an example in the
examples directory examples/coords_demo.py (works with Tk, GTK and WX)
that shows you how to get the mouse click coordinates. The examples
dir is your first line of defense when you want to figure out
something new. Unfortunately, I forgot to upload the zip file with
the 0.54.2 release, so look here
 http://matplotlib.sf.net/examples
Here's the example:
#!/usr/bin/env python
"""
An example of how to use wx or wxagg in an application w/o the toolbar
"""
from matplotlib.numerix import arange, sin, pi
import matplotlib
matplotlib.use('WX')
from matplotlib.backends.backend_wx import FigureCanvasWx as FigureCanvas
from matplotlib.figure import Figure
from wxPython.wx import *
class CanvasFrame(wxFrame):
 
 def __init__(self):
 wxFrame.__init__(self,None,-1,
 'CanvasFrame',size=(550,350))
 self.SetBackgroundColour(wxNamedColor("WHITE"))
 self.figure = Figure(figsize=(5,4), dpi=100)
 self.ax = self.figure.add_subplot(111)
 t = arange(0.0, 2.0, 0.01)
 s = sin(2*pi*t)
 l = self.ax.plot(t, s, linewidth=1.0)
 self.ax.set_xlabel('time (s)')
 self.ax.set_ylabel('voltage (mV)')
 self.ax.set_title('About as simple as it gets, folks')
 self.ax.legend(('line',), loc='upper right')
 for i in range(100):
 self.ax.grid(True)
 self.canvas = FigureCanvas(self, -1, self.figure)
 self.sizer = wxBoxSizer(wxVERTICAL)
 self.sizer.Add(self.canvas, 1, wxTOP | wxLEFT | wxEXPAND)
 # Capture the paint message 
 EVT_PAINT(self, self.OnPaint) 
 def OnPaint(self, event):
 self.canvas.draw()
 
class App(wxApp):
 
 def OnInit(self):
 'Create the main window and insert the custom frame'
 frame = CanvasFrame()
 frame.Show(true)
 return true
app = App(0)
app.MainLoop()
From: Schalkwyk, J. <Joh...@sc...> - 2004年06月29日 13:42:00
Thank you for the help
I removed the show() command from the loop. Now just calling grid(True)
multiple times. On my machine I narrowed the loop to 57 and it started
happening. At 50 it did not. 
Another way I found to trigger this problem is to remove the for loop all
together. Then it just pops up the display. Now grab the window with the
mouse and shake the window continuously around, forcing multiple Paint
events. Eventually it triggers the assert. The application I am developing
using multiple matplotlib windows in an MDI window seems to trigger this
quite easily. Everytime a window is added to the MDIParent all MDIChild
windows gets repainted. Something to do with the paint event.
By the way Kudos for matplotlib. Amazing. I had to dig around the code and
news groups to figure out how to find the user coordinates of a mouse click.
Reading the code opens your eyes the wonderful design that is backend
dependent.
import wx
import matplotlib
import time
matplotlib.use('WX')
from matplotlib.matlab import *
class App(wx.App):
 """Application class."""
 def OnInit(self):
 t = arange(0.0, 2.0, 0.01)
 s = sin(2*pi*t)
 l = plot(t, s, linewidth=1.0)
 xlabel('time (s)')
 ylabel('voltage (mV)')
 title('About as simple as it gets, folks')
 legend('line', loc='upper right')
 
 for i in range(100):
 grid(True)
 return True
#---------------------------------------------------------------------------
# run the app
app = App()
app.MainLoop()
-----Original Message-----
From: John Hunter [mailto:jdh...@ac...] 
Sent: Monday, June 28, 2004 11:17 PM
To: Schalkwyk, Johan
Cc: mat...@li...
Subject: Re: [Matplotlib-users] Assertion triggered in wxMemory DC
>>>>> "Schalkwyk," == Schalkwyk, Johan <Joh...@sc...>
writes:
 Schalkwyk,> The code snippet below reproduces the
 Schalkwyk,> problem. Basically calling "show()" in a loop forces
 Schalkwyk,> repaint of the same window many times. After a while a
 Schalkwyk,> strange stack trace appears with the assertion
 Schalkwyk,> above. Sometimes the stack trace creates garbage all
 Schalkwyk,> over the screen which has to be cleared by repainting
 Schalkwyk,> the whole screen.
You should only call show at most once per matplotlib script - for
more information on show see http://matplotlib.sf.net/faq.html#SHOW.
When embedding matplotlib in an application, typically you won't use
show at all.
When embedding matplotlib in a GUI like WX, you should use
canvas.draw() to repaint the figure. See embedding_in_wx.py in the
examples directory of the matplotlib src distribution of the script
embedding_in_wx2.py attached with this email for an example of how to
use matplotlib in a wx app.
I can't promise you this will fix your problem, but will at least make
your example consistent with how matplotlib is meant to be used in a
wx app. If you still get a problem, please post the revised code and
I'll take a look.
Good luck!
JDH
#!/usr/bin/env python
"""
An example of how to use wx or wxagg in an application w/o the toolbar
"""
from matplotlib.numerix import arange, sin, pi
import matplotlib
# uncomment the following to use wx rather than wxagg
#matplotlib.use('WX')
#from matplotlib.backends.backend_wx import FigureCanvasWx as FigureCanvas
# comment out the following to use wx rather than wxagg
matplotlib.use('WXAgg')
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as
FigureCanvas
from matplotlib.figure import Figure
from wxPython.wx import *
class CanvasFrame(wxFrame):
 
 def __init__(self):
 wxFrame.__init__(self,None,-1,
 'CanvasFrame',size=(550,350))
 self.SetBackgroundColour(wxNamedColor("WHITE"))
 self.figure = Figure(figsize=(5,4), dpi=100)
 self.axes = self.figure.add_subplot(111)
 t = arange(0.0,3.0,0.01)
 s = sin(2*pi*t)
 
 self.axes.plot(t,s)
 self.canvas = FigureCanvas(self, -1, self.figure)
 self.sizer = wxBoxSizer(wxVERTICAL)
 self.sizer.Add(self.canvas, 1, wxTOP | wxLEFT | wxEXPAND)
 # Capture the paint message 
 EVT_PAINT(self, self.OnPaint) 
 def OnPaint(self, event):
 self.canvas.draw()
 
class App(wxApp):
 
 def OnInit(self):
 'Create the main window and insert the custom frame'
 frame = CanvasFrame()
 frame.Show(true)
 return true
app = App(0)
app.MainLoop()
From: John H. <jdh...@ac...> - 2004年06月29日 03:47:33
>>>>> "Andrew" == Andrew Straw <str...@as...> writes:
 Andrew> Hi plotters, I've shamelessly modified dynamic_demo_wx.py
 Andrew> to create dynamic_image_wxagg.py, attached. This is my
 Andrew> initial attempt to get matplotlib to dynamically update
 Andrew> images. Basically it all works hunky-dory except 1) an
 Andrew> apparent memory leak and 2) flicker when I run this in
 Andrew> linux (haven't tested other OSes). I offer #1 to John or
 Andrew> other memory-leak hunters out there and ask if any WXpert
 Andrew> can address #2. I've googled a bit and it appears the WX
 Andrew> backend (from which WXAgg is derived) does the Right Thing
 Andrew> and calls wxClientDC on a non-OS generated redraw request,
 Andrew> which is supposed to reduce or eliminate flicker. The
 Andrew> other tip is to catch EVT_ERASE_BACKGROUND, which I've
 Andrew> also done to no apparent improvement. Thus, I ask for help
 Andrew> -- any suggestions on how to eliminate this flicker?
Hi Andrew,
Haven't had a chance to test your example yet but hopefully I can take
a look tomorrow. I haven't done much memory leak testing against the
_image module yet so this will be a good opportunity. I very recently
rewrote _image.cpp using cxx. I trust you have a fresh CVS checkout?
As for the flicker problem, I've noticed it too, and would also be
thankful if any wx gurus have some advice.
BTW, wxagg currently uses a string copy in python to render agg to a
wx bitmap via a wx image. It would be nice if some enterprising
soul wrote some extension code ala _tkagg.cpp and _gtkagg.cpp which
transfers the agg canvas to wx directly. Should be a pretty big win
performance wise. We could keep the string method as a fallback in
case the extension wasn't compiled, but it would help for people who
want to use wxagg for dynamic applications (hint hint). 
This should at least be on the goals page.
JDH
From: John H. <jdh...@ac...> - 2004年06月29日 03:40:44
>>>>> "Schalkwyk," == Schalkwyk, Johan <Joh...@sc...> writes:
 Schalkwyk,> The code snippet below reproduces the
 Schalkwyk,> problem. Basically calling "show()" in a loop forces
 Schalkwyk,> repaint of the same window many times. After a while a
 Schalkwyk,> strange stack trace appears with the assertion
 Schalkwyk,> above. Sometimes the stack trace creates garbage all
 Schalkwyk,> over the screen which has to be cleared by repainting
 Schalkwyk,> the whole screen.
You should only call show at most once per matplotlib script - for
more information on show see http://matplotlib.sf.net/faq.html#SHOW.
When embedding matplotlib in an application, typically you won't use
show at all.
When embedding matplotlib in a GUI like WX, you should use
canvas.draw() to repaint the figure. See embedding_in_wx.py in the
examples directory of the matplotlib src distribution of the script
embedding_in_wx2.py attached with this email for an example of how to
use matplotlib in a wx app.
I can't promise you this will fix your problem, but will at least make
your example consistent with how matplotlib is meant to be used in a
wx app. If you still get a problem, please post the revised code and
I'll take a look.
Good luck!
JDH
#!/usr/bin/env python
"""
An example of how to use wx or wxagg in an application w/o the toolbar
"""
from matplotlib.numerix import arange, sin, pi
import matplotlib
# uncomment the following to use wx rather than wxagg
#matplotlib.use('WX')
#from matplotlib.backends.backend_wx import FigureCanvasWx as FigureCanvas
# comment out the following to use wx rather than wxagg
matplotlib.use('WXAgg')
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas
from matplotlib.figure import Figure
from wxPython.wx import *
class CanvasFrame(wxFrame):
 
 def __init__(self):
 wxFrame.__init__(self,None,-1,
 'CanvasFrame',size=(550,350))
 self.SetBackgroundColour(wxNamedColor("WHITE"))
 self.figure = Figure(figsize=(5,4), dpi=100)
 self.axes = self.figure.add_subplot(111)
 t = arange(0.0,3.0,0.01)
 s = sin(2*pi*t)
 
 self.axes.plot(t,s)
 self.canvas = FigureCanvas(self, -1, self.figure)
 self.sizer = wxBoxSizer(wxVERTICAL)
 self.sizer.Add(self.canvas, 1, wxTOP | wxLEFT | wxEXPAND)
 # Capture the paint message 
 EVT_PAINT(self, self.OnPaint) 
 def OnPaint(self, event):
 self.canvas.draw()
 
class App(wxApp):
 
 def OnInit(self):
 'Create the main window and insert the custom frame'
 frame = CanvasFrame()
 frame.Show(true)
 return true
app = App(0)
app.MainLoop()
From: John H. <jdh...@ac...> - 2004年06月29日 03:27:39
>>>>> "Charles" == Charles R Twardy <cha...@in...> writes:
 Charles> Wow, matplot sure has grown up since I last saw it
 Charles> (0.32?). I was trying to get back in the game and tried
 Charles> the debian packages from mentors.
Hi Charles, glad to see you back.
 Charles> But I can only see the python-matplotlib-doc, not
 Charles> python-matplotlib. I'm guessing it hasn't been built for
 Charles> PowerPC. I'll try apt-get source when mentors.debian is
 Charles> back up (or when I can see it anyway).
I CCd Vittorio, the debian maintainer. I don't know if he's on the
user list. He may have some comments for you.
Cheers,
JDH
From: Schalkwyk, J. <Joh...@sc...> - 2004年06月28日 14:40:34
I've been using matplotlib in a WX application. The particular application
can uses many matplotlib figures within a MDI window class. The problem
appears when there are about seven windows active in the MDI, and an eight
is added. This causes a repaint of all seven matplotlib figures, which then
triggers the following assertion
 
PyAssertionError: C++ assertion "wxAssertFailure" failed in
"..\src\msw\dcmemory.cpp (133): Couldn't select a bitmap into wxMemoryDC
 
This appears on windows XP professional, Python 2.3, wxPython 2.5.1.5,
matplotlib 0.54.
 
The code snippet below reproduces the problem. Basically calling "show()" in
a loop forces repaint of the same window many times. After a while a strange
stack trace appears with the assertion above. Sometimes the stack trace
creates garbage all over the screen which has to be cleared by repainting
the whole screen.
 
 
import wx
import matplotlib
matplotlib.use('WX')
 
from matplotlib.matlab import *
 
class App(wx.App):
 """Application class."""
 
 def OnInit(self):
 t = arange(0.0, 2.0, 0.01)
 s = sin(2*pi*t)
 l = plot(t, s, linewidth=1.0)
 xlabel('time (s)')
 ylabel('voltage (mV)')
 title('About as simple as it gets, folks')
 legend('line', loc='upper right')
 for i in range(100):
 grid(True)
 show()
 # end for
 
 return True
 
#---------------------------------------------------------------------------
# run the app
app = App()
app.MainLoop()
From: Charles R. T. <cha...@in...> - 2004年06月28日 02:56:20
Wow, matplot sure has grown up since I last saw it (0.32?). I was trying
to get back in the game and tried the debian packages from mentors.
But I can only see the python-matplotlib-doc, not python-matplotlib.
I'm guessing it hasn't been built for PowerPC. I'll try apt-get source
when mentors.debian is back up (or when I can see it anyway).
-C
-- 
Charles R. Twardy www.csse.monash.edu.au/~ctwardy
Monash University sarbayes.org
Computer Sci. & Software Eng. +61(3) 9905 5823 (w) 5146 (fax)
Allow the president to invade a neighboring nation, whenever he shall
deem it necessary to repel an invasion, ... and you allow him to make
war at pleasure. --Abraham Lincoln
From: Andrew S. <str...@as...> - 2004年06月26日 08:32:11
Sorry, I also added the following line to backend_wxagg to get my demo 
to work:
from backend_wx import FigureManager
Anyhow, I've added this to CVS, but you can just as easily modify your 
copy of the affected file.
Cheers!
Andrew
From: Andrew S. <str...@as...> - 2004年06月26日 07:56:31
Attachments: dynamic_image_wxagg.py
Hi plotters,
I've shamelessly modified dynamic_demo_wx.py to create 
dynamic_image_wxagg.py, attached. This is my initial attempt to get 
matplotlib to dynamically update images. Basically it all works 
hunky-dory except 1) an apparent memory leak and 2) flicker when I run 
this in linux (haven't tested other OSes). I offer #1 to John or other 
memory-leak hunters out there and ask if any WXpert can address #2. 
I've googled a bit and it appears the WX backend (from which WXAgg is 
derived) does the Right Thing and calls wxClientDC on a non-OS generated 
redraw request, which is supposed to reduce or eliminate flicker. The 
other tip is to catch EVT_ERASE_BACKGROUND, which I've also done to no 
apparent improvement. Thus, I ask for help -- any suggestions on how to 
eliminate this flicker?
John -- feel free to stick this in examples if you think it's worthy.
Cheers!
Andrew
From: John H. <jdh...@ac...> - 2004年06月24日 21:22:56
>>>>> "Daniele" == Daniele Varrazzo <dva...@vi...> writes:
 Daniele> I am testing matplotlib for the first time, but it
 Daniele> continuously hang after a really short time.
 Daniele> I read all the troubles about running it from an ide, so
 Daniele> i'm using plain cmd.
...snip...
 Daniele> The Python prompt is still functional. When i try to exit
 Daniele> i get (WXAgg backend):
Even in plain command mode "shell", you need a special shell to work
interactively, or you need to use TkAgg. WX* and GTK* both require
special shells to work interactively. It looks from your post that
you are trying to use wxagg from the standard python shell. This is
known not to work. If you want wx + interactive shell, try pycrust.
This is discussed on
http://matplotlib.sourceforge.net/interactive.html.
Your best bet for interactive use on win32 is TkAgg.
You should try setting in C:\Python23\share\matplotlib\.matplotlibrc
backend : TkAgg 
interactive : True
and try using either the standard python shell or ipython. If that
works, you should look at the additional setting in your rc file
tk.window_focus : True # Maintain shell focus for TkAgg
Hope this helps,
John Hunter 
From: <mai...@ya...> - 2004年06月24日 18:04:12
Dear all,
A few days ago, I was trying to install matplotlib
into os x 10.2, with the help from John I have managed
to get it to work at the end. 
So please find the following information useful if you
are thinking of building one under the os x Jaguar
environment.
System information: Mac OS X 10.2.8, gcc version 3.1,
 Apple X11 Beta 3 and Fink
installed
* make sure zlib, libpng and freetype2 are installed 
 either in /usr/local or /sw. If you are fink user, 
 don't install freetype. If you have, remove it, 
 becuase it will cause confusion for the package to 
 config later on
* install Numeric or numarray (I did it through 
 fink, no problem) and change the NUMERIX setting in
 setup.py and .matplotlibrc accordingly
* I have also installed pygtk through fink as my 
 alternative GUI framework (you don't have to if
 you don't want it). If you do, you need to add an
 extra line onto your .cshrc or .tcshrc to tell where
 pkgconfig is on your path (I did the installation 
 through fink)
 setenv PKG_CONFIG_PATH "/sw/lib/pkgconfig"
* Now X11, if you are using Apple X11 Beta 3, you also
 need the X11 SDK installed. Then if you haven't 
 done it, you should also install system-xfree86-42
 through fink so that all the required header files
 will be in /usr/X11R6/include/X11 and all the
library
 files will be in /sw directory
 Up to this point if you don't do anything on the
 path setting for the X11 header files, you would get
 errors like tk.h/tcl.h couldn't find the X11/Xlib.h
 file when you compile. There are two ways to tackle
 this, depending your own preference. I believe
 they both work eventually.
 1) create symbolic link from /usr/X11R6/include/X11
 to /sw/include/X11, I think the command is like
 this (correct me if I am wrong)
 
 ln -s /usr/X11R6/include/X11 /sw/include/
 2) include /usr/X11R6/include/X11 as basedir into 
 your setupext.py of matplotlib
* change the basdir in setupext.py into either
 'darwin':['/sw'] or 
 'darwin':['/usr/X11R6/include/X11','/sw']
 according to what you did in previous step
* type 'python setup.py insatll' in root mode or
 type 'sudo python setup.py install' otherwise,
 sit back and the installation process should go
 smoothly
Cheers,
Denis 
 
	
	
		
___________________________________________________________ALL-NEW Yahoo! Messenger - sooooo many all-new ways to express yourself http://uk.messenger.yahoo.com
From: Daniele V. <dva...@vi...> - 2004年06月24日 16:59:58
I am testing matplotlib for the first time, but it continuously hang after a
really short time.
I read all the troubles about running it from an ide, so i'm using plain
cmd.
Microsoft Windows 2000 [Versione 5.00.2195]
(C) Copyright 1985-2000 Microsoft Corp.
C:\Documents and Settings\daniele>python
Python 2.3.4 (#53, May 25 2004, 21:17:02) [MSC v.1200 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from matplotlib.matlab import *
>>> t = arange(0.0, 5.2, 0.2)
>>> plot(t, t, 'r--', t, t**2, 'bs', t, t**3, 'g^')
[<matplotlib.lines.Line2D instance at 0x0100F6E8>, <matplotlib.lines.Line2D
inst
ance at 0x0100F788>, <matplotlib.lines.Line2D instance at 0x0100F7B0>]
The window pops up as expected. Now i switch to an ie window to watch online
docs looking for axis command syntax...
When i'm back to the prompt, the plot window is frozen. If visualized it
doesn't redraw itself and clicking on the close button in the menu bar pops
it up the not-responding-app dialog.
The Python prompt is still functional. When i try to exit i get (WXAgg
backend):
>>> ^Z
Fatal Python error: PyEval_RestoreThread: NULL tstate
abnormal program termination
C:\Documents and Settings\daniele>
The problem doesn't depend from the backend used: i tried, TkAgg, WX, WXAgg.
Sontimes i can add a title to a graph but it will always hang within a
minute.
I have a pretty fresh installation of Python 2.3.4 with numpy 0.9. I used
matplotlib-0.54.2-numarray0.9.win32-py2.3.exe. I also tried to use
matplotlib 0.54.1 but it looks like it need numpy to work (i think it's
wrong, i installed the numarray version) and i don't want to install it. No
tries with other releases. I currently don't have any problem in running
neither wxwindows nor tk apps.
Does anybody experienced the same problem?
Regards
--
Daniele Varrazzo
Dipartimento di Biologia Molecolare
Universita' di Siena
Via Fiorentina, 1 53100 SIENA (Italy)
From: Gregory L. <gre...@ff...> - 2004年06月24日 12:56:13
I checked on another WinXP computer, and it works on this one - seems
that I have to play the windows re-install game, or hunt down what the
exact differences between these 2 WinXP computers are :-/... 
The fact that only matplotlib exhibit this behavior is strange though, I
checked in the code (hence cc to the devel list) and the problem is
linked to an assert in the destructor of PythonExtensionBase, checking
that the ref counting of this object is 0 and exiting Python interpreter
if it is not the case...Hum, obviously I do not know the code at all,
but could the problem be linked to a destruction sequence beeing
somewhat different on my computer (for whatever reasons :-/)? 
This worry me (in addition to bother me not beeing able to run
matplotlib on my laptop for the moment ;-) ), cause it may be the sign
of "difficult to solve and reproduce" installation problems for a
package we may use in a distributed software package in the future...
I will keep investigating, but if there is a developer have any idea
about this (like, a hint about why there is this assert there and what
can cause it to fail), it would be great!
Thanks a lot, and congratulation for matplotlib, it looks the most
promising python plotting packages I have found yet! :-)
From: Gregory L. <gre...@ff...> - 2004年06月24日 11:32:23
Thanks for helping with this problem!
I just tried on a win2000 Pro computer, and indeed, no problem...
Then, on my WinXP laptop, I removed python, reinstalled it (2.3.4), next
numarray (0.9), then matplotlib (0.54.2), the exact same windows
installers that were used on the Win2000 computer, and same problem as
before, crash on matplotlib.matlab import...Weird!
I will try to perform the same installation on another WinXP computer,
to be sure the problem is not related to incompatibilities with other
softwares installed on my laptop, or some registery entries, and keep
the list informed of the results of this test.
Best regards,
Greg.
From: Philippe B. <pb...@pa...> - 2004年06月24日 06:40:55
Todd Miller <jm...@st...> =E9crit :
> > I just tried to install matplotlib on a WinXP computer, after a
> > successfull install on Linux.
> > The problem I encounter is the following (transcript of an
> > interractive session):=20
> > Python 2.3.4 (#53, May 25 2004, 21:17:02) [MSC v.1200 32 bit (Intel)]
> > on win32
> > Type "help", "copyright", "credits" or "license" for more information.
> > >>> import matplotlib
> > >>> matplotlib.use("TkAgg")
> > >>> from matplotlib.matlab import *
> > Assertion failed: ob_refcnt =3D=3D 0, file CXX/cxx_extensions.cxx, li=
ne
> > 1031
> I tried this configuration on Windows 2000 Pro and it worked fine.
> I haven't tried this configuration on Windows XP yet... I'll try later
> to see if I can reproduce the problem.
I tried this code with WinXP version 5.1 and python 2.3.2, and I
have not problem it's Ok :-)
 Philippe Bouige
From: Todd M. <jm...@st...> - 2004年06月23日 20:48:50
On Wed, 2004年06月23日 at 12:42, Gregory Lielens wrote:
> Hello All,
> I just tried to install matplotlib on a WinXP computer, after a
> successfull install on Linux.
> The problem I encounter is the following (transcript of an
> interractive session): 
> 
> ---
> C:\Python23>python
> Python 2.3.4 (#53, May 25 2004, 21:17:02) [MSC v.1200 32 bit (Intel)]
> on win32
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import matplotlib
> >>> matplotlib.use("TkAgg")
> >>> from matplotlib.matlab import *
> Assertion failed: ob_refcnt == 0, file CXX/cxx_extensions.cxx, line
> 1031
> 
> This application has requested the Runtime to terminate it in an
> unusual way.
> Please contact the application's support team for more information.
> 
> C:\Python23>
> 
> ---
> 
> This work on Linux, and I can not find any hint in the doc to a
> backend/python interpreter incompatibility explaining this error.
> 
> I use numarray version 0.9 (win installer), python 2.3.4 (as shown in
> the session transcript), and matplotlib 0.54.2, last windows installer
> (the 2004年06月08日 21:54:42 build which I think correct some problems
> with numarray)
> 
> Now I am wondering if I do something I shouldn't, if my system or
> installation is responsible, or if it is a bug in this particular
> matplotlib distribution...Any idea? 
I tried this configuration on Windows 2000 Pro and it worked fine.
I haven't tried this configuration on Windows XP yet... I'll try later
to see if I can reproduce the problem.
Regards,
Todd
From: Gregory L. <gre...@ff...> - 2004年06月23日 16:43:46
Hello All,
I just tried to install matplotlib on a WinXP computer, after a
successfull install on Linux.
The problem I encounter is the following (transcript of an interractive
session): 
 
---
C:\Python23>python
Python 2.3.4 (#53, May 25 2004, 21:17:02) [MSC v.1200 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
>>> matplotlib.use("TkAgg")
>>> from matplotlib.matlab import *
Assertion failed: ob_refcnt == 0, file CXX/cxx_extensions.cxx, line 1031
 
This application has requested the Runtime to terminate it in an unusual
way.
Please contact the application's support team for more information.
 
C:\Python23>
 
---
 
This work on Linux, and I can not find any hint in the doc to a
backend/python interpreter incompatibility explaining this error.
 
I use numarray version 0.9 (win installer), python 2.3.4 (as shown in
the session transcript), and matplotlib 0.54.2, last windows installer
(the 2004年06月08日 21:54:42 build which I think correct some problems with
numarray)
 
Now I am wondering if I do something I shouldn't, if my system or
installation is responsible, or if it is a bug in this particular
matplotlib distribution...Any idea? 
 
Best regards,
 
Greg.
From: Perry G. <pe...@st...> - 2004年06月23日 15:10:22
John Hunter wrote:
> 
> Now on to your problem. This is caused by a difference in how Numeric
> and numarray treak rank 0 arrays
> 
> >>> from Numeric import asarray
> >>> len(asarray(0))
> 1
> >>> from numarray import asarray
> >>> len(asarray(0))
> Traceback (most recent call last):
> File "<stdin>", line 1, in ?
> ValueError: Rank-0 array has no length.
> 
> I don't know why there is this difference but I'm sure Todd or Perry
> can comment at length :-).
> 
Boy can we (and we have on the numpy list in the past). 
But I risk boring those who really don't care. The issue relates
to consistency. If rank-0 arrays have a shape of () (and they
do), then they:
1) should not be indexable.
2) they have no length.
Currently Numeric gives len=1 and allows indexing with [0]
It's seemed to me that we need some sort of construct similar to
array() that will turn scalars into rank-1 len-1 arrays which
can be used like scalars for broadcasting purposes (albeit with
different coercion rules; that's a different topic though), and
where len() and indexing will work.
Another proposal is to treat all arrays (including rank-0) as 
allowing indexing with any number of 0 indices beyond the defined shape:
I.e., if 
x = arange(10)
x[3,0] # same as x[3]
So it's a known issue and we are thinking about how best to solve it.
> To solve your vline problem, you need to make the vmin and vmax args
> of vlines (or hlines) iterable. Ie
> 
> old
> 
> vlines(t, 0, s, color='k')
> 
> new
> 
> vlines(t, [0], s, color='k')
> 
> Should work! Thanks for letting us know.
> 
> 
From: John H. <jdh...@ac...> - 2004年06月23日 12:14:15
>>>>> "Philippe" == Philippe Bouige <pb...@pa...> writes:
 Philippe> Hello,
 Philippe> I try 'vline_demo' in directory 'example' and I have
 Philippe> problem with vlines ... error : "rank-O array has no
 Philippe> length". I try also with hlines and I have the same
 Philippe> problem ...
 Philippe> I also this error with all the demo : error reading
 Philippe> package index file C:/Python23/tcl/tix8.1/pkgIndex.tcl:
 Philippe> invalid command name "lt}]}"
 Philippe> Have you a explanation ?
This turns out to be numarray specific - most of my tests use Numeric
which is why I didn't catch that. I'll try and make sure I do a
numarray specific test in the future. Todd, perhaps you should also
make a note to run backend_driver on your numarray build, at least for
Agg. That wouldn't have helped this time, because vline_demo.py was
not in the regression suite, but I've added it.
Now on to your problem. This is caused by a difference in how Numeric
and numarray treak rank 0 arrays
 >>> from Numeric import asarray
 >>> len(asarray(0))
 1
 >>> from numarray import asarray
 >>> len(asarray(0))
 Traceback (most recent call last):
 File "<stdin>", line 1, in ?
 ValueError: Rank-0 array has no length.
I don't know why there is this difference but I'm sure Todd or Perry
can comment at length :-).
To solve your vline problem, you need to make the vmin and vmax args
of vlines (or hlines) iterable. Ie
old
 vlines(t, 0, s, color='k')
new
 vlines(t, [0], s, color='k')
 
Should work! Thanks for letting us know.
John Hunter
From: Philippe B. <pb...@pa...> - 2004年06月22日 16:23:05
Hello,
 I try 'vline_demo' in directory 'example' and I have problem
 with vlines ... error : "rank-O array has no length". I try
 also with hlines and I have the same problem ...
 I also this error with all the demo :
 error reading package index file
 C:/Python23/tcl/tix8.1/pkgIndex.tcl: invalid command name "lt}]}"
 Have you a explanation ?
 
 Thank you very for your help
 (I work with python 2.3 / windowXP)
 Philippe
13 messages has been excluded from this view by a project administrator.

Showing results of 110

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