Re: [Matplotlib-users] Figure.draw_artist() bug with Text

2010-02-08 Thread Jae-Joon Lee
This is not a bug.
The exception is raised simply because "textartist.figure" is None
(and it is None because you never set it).
"textartist" you created is not properly set up (no figure, no axes,
no transform). You may do

textartist = Text(0.5, 0.5, "Foo")
textartist.set_figure(fig)
fig.draw_artist(textartist)
fig.canvas.blit(fig.bbox)

But, this is not the recommended way of doing things.
draw_artist is mainly for doing animation.

http://matplotlib.sourceforge.net/examples/animation/index.html

Regards,

-JJ

On Mon, Feb 8, 2010 at 4:24 PM, Ben Axelrod  wrote:
> I am getting a fault when I try to use Figure.draw_artist() with a 
> matplotlib.text.Text object.  Since matplotlib.text.Text inherits from 
> matplotlib.artist.Artist, which is what draw_artist() takes, this should 
> probably work.
>
> Tested with latest SVN code on Linux.
>
> Here is the traceback:
>
> Traceback (most recent call last):
>  File "test.py", line 10, in 
>    fig.draw_artist(textartist)
>  File "/usr/local/lib/python2.6/site-packages/matplotlib/figure.py", line 
> 816, in draw_artist
>    a.draw(self._cachedRenderer)
>  File "/usr/local/lib/python2.6/site-packages/matplotlib/artist.py", line 55, 
> in draw_wrapper
>    draw(artist, renderer, *kl)
>  File "/usr/local/lib/python2.6/site-packages/matplotlib/text.py", line 549, 
> in draw
>    bbox, info = self._get_layout(renderer)
>  File "/usr/local/lib/python2.6/site-packages/matplotlib/text.py", line 267, 
> in _get_layout
>    key = self.get_prop_tup()
>  File "/usr/local/lib/python2.6/site-packages/matplotlib/text.py", line 716, 
> in get_prop_tup
>    self.figure.dpi, id(self._renderer),
> AttributeError: 'NoneType' object has no attribute 'dpi'
>
> And here is some simple code to trigger the bug:
>
> #!/usr/bin/env python
> # display bug in figure.draw_artist(matplotlib.text)
> import matplotlib.pyplot as plt
> from matplotlib.text import Text
>
> fig = plt.figure()
> plt.draw()
>
> textartist = Text(0.5, 0.5, "Foo")
> fig.draw_artist(textartist)
>
> plt.show()
> #end code
>
> Note that I still get the bug even when i specify figsize and dpi on the 
> figure like so:
> fig = plt.figure(figsize=(2,2), dpi=300)
>
> -Ben
> --
> The Planet: dedicated and managed hosting, cloud storage, colocation
> Stay online with enterprise data centers and the best network in the business
> Choose flexible plans and management services without long-term contracts
> Personal 24x7 support from experience hosting pros just a phone call away.
> http://p.sf.net/sfu/theplanet-com
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>

--
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Surface Plot

2010-02-08 Thread PHobson
Ted,

How does this example run for you?
http://matplotlib.sourceforge.net/examples/pylab_examples/griddata_demo.html

From: Ted Kord [mailto:teddy.k...@googlemail.com]
Sent: Monday, February 08, 2010 12:00 PM
To: Paul Hobson
Cc: matplotlib-users@lists.sourceforge.net
Subject: Re: [Matplotlib-users] Surface Plot

On 8 February 2010 17:37, mailto:phob...@geosyntec.com>> 
wrote:
Hey Ted,

I don't quite understand how you're getting the Z data below. But if you have 
3D data in X, Y, and Z 1D-arrays, the griddata function should work for you.
http://matplotlib.sourceforge.net/api/mlab_api.html#matplotlib.mlab.griddata

HTH,
-paul

Hi  Paul

Is there a way to colour the output? For some reason, the final output is in a 
single colour even though I've specified cm.jet for the colour map.

Regards

Ted

--
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Figure.draw_artist() bug with Text

2010-02-08 Thread Ben Axelrod
I am getting a fault when I try to use Figure.draw_artist() with a 
matplotlib.text.Text object.  Since matplotlib.text.Text inherits from 
matplotlib.artist.Artist, which is what draw_artist() takes, this should 
probably work.

Tested with latest SVN code on Linux.

Here is the traceback:

Traceback (most recent call last):
  File "test.py", line 10, in 
fig.draw_artist(textartist)
  File "/usr/local/lib/python2.6/site-packages/matplotlib/figure.py", line 816, 
in draw_artist
a.draw(self._cachedRenderer)
  File "/usr/local/lib/python2.6/site-packages/matplotlib/artist.py", line 55, 
in draw_wrapper
draw(artist, renderer, *kl)
  File "/usr/local/lib/python2.6/site-packages/matplotlib/text.py", line 549, 
in draw
bbox, info = self._get_layout(renderer)
  File "/usr/local/lib/python2.6/site-packages/matplotlib/text.py", line 267, 
in _get_layout
key = self.get_prop_tup()
  File "/usr/local/lib/python2.6/site-packages/matplotlib/text.py", line 716, 
in get_prop_tup
self.figure.dpi, id(self._renderer),
AttributeError: 'NoneType' object has no attribute 'dpi'

And here is some simple code to trigger the bug:

#!/usr/bin/env python
# display bug in figure.draw_artist(matplotlib.text)
import matplotlib.pyplot as plt
from matplotlib.text import Text

fig = plt.figure()
plt.draw()

textartist = Text(0.5, 0.5, "Foo")
fig.draw_artist(textartist)

plt.show()
#end code

Note that I still get the bug even when i specify figsize and dpi on the figure 
like so:
fig = plt.figure(figsize=(2,2), dpi=300)

-Ben
--
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Matplotlib Online: HOW TO?

2010-02-08 Thread Christopher Barker
Adolfo Aguirre wrote:
> He´s answer was that Zope awas not an straightforward stable 
> environment but a work-in-progress,

Zope has been around a long time, it' s fine environment, particularly 
when used as the core of Plone. Zope does have its own way of doing 
things that are not to everyone's taste. If your admin folks don't like 
it, there are MANY other ways to build a web app with Python.

MPL should work with any Python web application framework that allows 
arbitrary python packages, which is probably every one.

I'd take a look at Django, Pylons and Turbogears, at least.

 > and that he did not find a single
> straight way to put matyplotlib online.

He was not looking very hard.

On the other had, if you have a well established set of web services 
built on PHP, they may not want to build something new, but I'll bet you 
could still use MPL to do your plotting by calling Python as a separate 
process. You could even get fancy and build a web service that does the 
plotting, and have your web apps call that (Pylons would be good for 
that, it's very flexible)


> in case we are missing something.

I think you are -- MPL is a fine choice for putting plots on the web. 
PHPlot may be also -- I know nothing of it.

HTH,

-Chris



-- 
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R(206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115   (206) 526-6317   main reception

chris.bar...@noaa.gov


--
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] trying to Copy plot from one MplWidget canvas to another

2010-02-08 Thread Dave . M . Tung

Hey folks,

my problem may be obvious, but i can't seem to copy a plot from one canvas
to another.

# I have this object   where whichCanvas is an instance of  MplWidget (code
shown below)

   self.whichCanvas.canvas.ax.plot(xData, yData, 'bo', linewidth=1.5,
linestyle='-')




# I want to copy the plot and axes  to another MplWidget object

  self.anotherCanvas.canvas



I've tried:

self.anotherCanvas.canvas.ax = self.whichCanvas.canvas.ax
self.anotherCanvas.canvas.draw()

and

self.anotherCanvas.canvas = self.whichCanvas.canvas
self.anotherCanvas.canvas.draw()

the plot doesn't seem to copy.  Does any body more familiar with matplotlib
have any suggestions?





This is the MplWidget Class
* MplWidget ***

from PyQt4 import QtGui
from matplotlib.backends.backend_qt4agg \
import FigureCanvasQTAgg as FigureCanvas
from matplotlib.figure import Figure




class MplCanvas(FigureCanvas):
def __init__(self):
self.fig = Figure()
self.ax = self.fig.add_subplot(111)
FigureCanvas.__init__(self, self.fig)
FigureCanvas.setSizePolicy(self,
QtGui.QSizePolicy.Expanding,
QtGui.QSizePolicy.Expanding)
FigureCanvas.updateGeometry(self)




class MplWidget(QtGui.QWidget):

def __init__(self, parent = None):
QtGui.QWidget.__init__(self, parent)
self.canvas = MplCanvas()
self.vbl = QtGui.QVBoxLayout()
self.vbl.addWidget(self.canvas)
self.setLayout(self.vbl)



Regards,
Dave Tung

cell: 925-321-6657
office: 510-353-4770
dave.m.t...@seagate.com--
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Surface Plot

2010-02-08 Thread Ted Kord
On 8 February 2010 17:37,  wrote:

> Hey Ted,
>
> I don't quite understand how you're getting the Z data below. But if you
> have 3D data in X, Y, and Z 1D-arrays, the griddata function should work for
> you.
>
> http://matplotlib.sourceforge.net/api/mlab_api.html#matplotlib.mlab.griddata
>
> HTH,
> -paul
>
>
Hi  Paul

Is there a way to colour the output? For some reason, the final output is in
a single colour even though I've specified cm.jet for the colour map.

Regards

Ted
--
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] help with view_limits

2010-02-08 Thread C M
I'd like to set the ticks on the y axis such that they do not display
anything lower than 0, even if part of the graph below 0 is visible.
I tried to do this with

ylocator = AutoLocator()
ylocator.view_limits(0, 100)
self.subplot.yaxis.set_major_locator(ylocator)

but it is not changing anything.  How can I do this?

Thank you,
Che

--
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] OS X backend on 10.6 produces truncated plot labels

2010-02-08 Thread Art
On Mac OS X 10.6.2, with Sage 4.3.1, I have installed matplotlib-0.99.1 with
gui backend (to do this, I set SAGE_MATPLOTLIB_GUI=True before using sage's
spkg installer, which performs some patches on matplotlib that ).

When I use the OS X backend and do:

import matplotlib.pyplot as plt
plt.figure()
plt.plot([1,2,3,4])

I get a plot that has as evenly spaced x-labels [0.,0.,1.,1.,2.,2.,3.] and
y-labels [1.,1.,2.,2.,3.,3.,4.].

If I try,

plt.plot([10, 20, 30, 40])

I get y-labels [1,1,2,2,3,3,4]. It seems there is an issue with rendering
the last digit for the labels.

If I use the TkAgg backend, the axes are labeled correctly.

However, on the same machine, with EPD 6.0 installed and Mac OX backend, the
labels are correct.

Any tips, even temorary workaround would be appreciated. I primarily use
sage, but in the default build, it doesn't include a gui backend. Wanted to
check here before I ask the sage users list.

Art.
--
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Matplotlib Online: HOW TO?

2010-02-08 Thread Sean Arms
Greetings Adolfo,

On Mon, Feb 8, 2010 at 12:18 PM, Adolfo Aguirre
 wrote:
> Hi:
>
> I do environmental research that requires almost real time online graphing
> for data originating in the field.

Can you be a little more specific regarding 'almost real time?'  I
update data from a remote meteorological research sites.  Data streams
to the computer every minute and is dumped to plain ascii files.  I
use pyinotify to watch for the new files to arrive, then execute my
analysis/plotting routines which produce plots; The plots are then
pushed to our webserver.

Sean

> I am a fan of Phyton thus I commissioned
> a systems administrator to figure out how to put Matplotlib online. He´s
> answer was that Zope awas not an straightforward stable environment but a
> work-in-progress, and that he did not find a single straight way to put
> matyplotlib online. He suggested PHPlot.
>
> I like the plotting I do with Mathplotlib on my computer  thus I wanted to
> ask matplotlib users about it, in case we are missing something.
>
> Appreciating your help,
>
> Adolfo
>
> --
> The Planet: dedicated and managed hosting, cloud storage, colocation
> Stay online with enterprise data centers and the best network in the
> business
> Choose flexible plans and management services without long-term contracts
> Personal 24x7 support from experience hosting pros just a phone call away.
> http://p.sf.net/sfu/theplanet-com
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>

--
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] vector EPS

2010-02-08 Thread James Cloos
> "M" == Michael Droettboom  writes:

M> Matplotlib will output Type 42 fonts if the rcParam "ps.fonttype"
M> is set to 42.

I read the reply which stated that after sending mine

Sorry for the noise.

-JimC
-- 
James Cloos  OpenPGP: 1024D/ED7DAEA6

--
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Surface Plot

2010-02-08 Thread Ted Kord
Hi Paul

This helped immensely. Thanks.

Ted
--
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Matplotlib Online: HOW TO?

2010-02-08 Thread Adolfo Aguirre
Hi:

I do environmental research that requires almost real time online graphing
for data originating in the field. I am a fan of Phyton thus I commissioned
a systems administrator to figure out how to put Matplotlib online. He´s
answer was that Zope awas not an straightforward stable environment but a
work-in-progress, and that he did not find a single straight way to put
matyplotlib online. He suggested PHPlot.

I like the plotting I do with Mathplotlib on my computer  thus I wanted to
ask matplotlib users about it, in case we are missing something.

Appreciating your help,

Adolfo
--
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Surface Plot

2010-02-08 Thread PHobson
Hey Ted,

I don't quite understand how you're getting the Z data below. But if you have 
3D data in X, Y, and Z 1D-arrays, the griddata function should work for you. 
http://matplotlib.sourceforge.net/api/mlab_api.html#matplotlib.mlab.griddata

HTH, 
-paul

-
From: Ted Kord [mailto:teddy.k...@googlemail.com] 
Sent: Saturday, February 06, 2010 1:05 PM
To: matplotlib-users@lists.sourceforge.net
Subject: [Matplotlib-users] Surface Plot

Hi

I'd like to generate a surface plot using mplot3d. However, Z is not a function 
of X and/or Y. It's just a set of scalar values. So, the following doesn't work:

X = np.arange(2, 102, 2)
Y = np.arange(0, 15.15, 0.15)
X, Y = np.meshgrid(X, Y)
Z = f[2]
ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.jet) 

Is there a way that I can do this?

Thank you.

Ted

--
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] vector EPS

2010-02-08 Thread Michael Droettboom
Matplotlib will output Type 42 fonts if the rcParam "ps.fonttype" is set to 42. 
 Type 3 is the default because it greatly reduces filesize (it embeds only a 
subset of the font), particularly with large Unicode fonts like Vera Sans.

Mike

--
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Memory leak when destroying Tk frame containing a figure

2010-02-08 Thread Michael Droettboom
Have you tried explicitly calling .clf() on the matplotlib Figure object from 
your Tix.Frame.destroy callback?

Mike

--
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Axes3D rotation not working when embedded in backend

2010-02-08 Thread Ben Axelrod
One more note about Axes3D and mouse rotation.  Axes3D disconnects the mouse 
callbacks when cla() is called.  Which means that if you do this:

self.axes = Axes3D(self.figure)
self.axes.scatter(xs, ys, zs)
self.axes.cla()
self.axes.scatter(xs, ys, zs)

then the plot will have no mouse rotation.  To fix this, mouse_init() should be 
called after cla().  Currently, all of this is undocumented.  Is disconnecting 
mouse callbacks on cla() the preferred matplotlib way to do things?  Is it safe 
to *not* disconnect mouse callbacks on cla()?  Maybe there is another type of 
destructor that is more appropriate for this?

Thanks,
-Ben

-Original Message-
From: Ben Axelrod [mailto:baxel...@coroware.com] 
Sent: Saturday, February 06, 2010 5:55 PM
To: matplotlib-users@lists.sourceforge.net
Subject: Re: [Matplotlib-users] Axes3D rotation not working when embedded in 
backend

I looked into this issue a little bit and found that the FigureCanvas must be 
set on the Figure before the 3D axes is instantiated.  A simple re-ordering of 
the lines in the code below makes mouse rotation work again.

# ...
self.figure = Figure()
self.canvas = FigureCanvas(self, -1, self.figure) #You must set up the canvas 
before creating the 3D axes self.axes = Axes3D(self.figure) # ...

Perhaps this should be documented somehow?  Or maybe a new mplot3d example code 
should be added.  Or maybe
Axes3D.mouse_init() should warn the user if self.figure.canvas is None.

-Ben


-Original Message-
From: Ben Axelrod [mailto:baxel...@coroware.com]
Sent: Monday, February 01, 2010 3:56 PM
To: matplotlib-users@lists.sourceforge.net
Subject: [Matplotlib-users] Axes3D rotation not working when embedded in backend

I would like to use Axes3D embedded in Wx.  This works, but there is no mouse 
rotation.  Clicking and dragging the mouse on the plot does not rotate the 3D 
axes like it does in the "scatter3d_demo.py".  I tried: WX, WXAgg, and TkAgg 
with similar results.  Can this be fixed soon, or can someone point me to where 
I can try to fix it?

I tested with the latest SVN tree on Linux and Windows.

Thanks,
-Ben

Below is some sample code adapted from "embedding_in_wx2.py", but with an 
Axes3D instead of the regular plot:

#!/usr/bin/env python
# adapted from example code "embedding_in_wx2.py"

# Used to guarantee to use at least Wx2.8 import wxversion
wxversion.ensureMinimal('2.8')

import numpy as np

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.backends.backend_wx import NavigationToolbar2Wx

from matplotlib.figure import Figure
from mpl_toolkits.mplot3d import Axes3D
import wx

class CanvasFrame(wx.Frame):

def __init__(self):
wx.Frame.__init__(self,None,-1,
 'CanvasFrame',size=(550,350))

self.SetBackgroundColour(wx.NamedColor("WHITE"))

self.figure = Figure()
self.axes = Axes3D(self.figure)

xs = np.random.rand(100)
ys = np.random.rand(100)
zs = np.random.rand(100)
self.axes.scatter(xs, ys, zs)

self.canvas = FigureCanvas(self, -1, self.figure)

self.sizer = wx.BoxSizer(wx.VERTICAL)
self.sizer.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.GROW)
self.SetSizer(self.sizer)
self.Fit()

self.add_toolbar()  # comment this out for no toolbar


def add_toolbar(self):
self.toolbar = NavigationToolbar2Wx(self.canvas)
self.toolbar.Realize()
if wx.Platform == '__WXMAC__':
# Mac platform (OSX 10.3, MacPython) does not seem to cope with
# having a toolbar in a sizer. This work-around gets the buttons
# back, but at the expense of having the toolbar at the top
self.SetToolBar(self.toolbar)
else:
# On Windows platform, default window size is incorrect, so set
# toolbar width to figure width.
tw, th = self.toolbar.GetSizeTuple()
fw, fh = self.canvas.GetSizeTuple()
# By adding toolbar in sizer, we are able to put it at the bottom
# of the frame - so appearance is closer to GTK version.
# As noted above, doesn't work for Mac.
self.toolbar.SetSize(wx.Size(fw, th))
self.sizer.Add(self.toolbar, 0, wx.LEFT | wx.EXPAND)
# update the axes menu on the toolbar
self.toolbar.update()


def OnPaint(self, event):
self.canvas.draw()

class App(wx.App):

def OnInit(self):
'Create the main window and insert the custom frame'
frame = CanvasFrame()
frame.Show(True)

return True

app = App(0)
app.MainLoop()
#end code




-

Re: [Matplotlib-users] How to close a plot?

2010-02-08 Thread David MacQuigg


Jeff Whitaker wrote:
> 
> zxc wrote:
>> Hi there!
>> I need to know how to close a figure/chart in matplot.
>>
>> Does anyone know how it works and could you please explain on the 
>> example below?
>> The problem is: close(1)  doesn't close the figure 1 and when the 2nd 
>> figure will be plot the program hangs.
>> I tried with draw() but the figure doesn't appear.
> 
> Use fig.close()
> 

>>> fig.close()
Traceback (most recent call last):
 - - - 
AttributeError: 'Figure' object has no attribute 'close'

I think you mean plt.close().  This seems to suspend IDLE, and activate the
plot and console windows.  To get back, I use "exit" in the console window.

Try using the draw() command instead of show().  Sometimes you need to issue
this command twice.

If I ever get this figured out, I'll write a HOWTO note.

-- 
View this message in context: 
http://old.nabble.com/How-to-close-a-plot--tp27490895p27501480.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] quiver + dates

2010-02-08 Thread Filipe Pires Alvarenga Fernandes
Thanks, that worked perfectly.

Best, Filipe

On Mon, Feb 8, 2010 at 8:39 AM, Stephane Raynaud  wrote:

> Hi Filipe,
>
> you can fist use the quiver() function in the classic way for stick plots,
> then use gca().xaxis_date().
>
> Here is a simple example :
>
> import pylab as P
> # t may be generated using date2num()
> t = P.arange(100,110,.1)
> u = P.sin(t)
> v = P.cos(t)
> P.quiver([t],[[0]*len(t)],u,v)
> P.gca().xaxis_date()
> P.show()
>
>
> On Sun, Feb 7, 2010 at 6:11 PM, Filipe Pires Alvarenga Fernandes <
> ocef...@gmail.com> wrote:
>
>> Hello list,
>>
>> I'm trying to create a stick-plot figure using the quiver function from
>> matplotlib. However, I'm failing miserably to plot dates in the x-axis. Has
>> anyone done this before? Also, is there an effort to create a stickplot
>> function?
>>
>> Thanks, Filipe
>>
>> *
>> Filipe Pires Alvarenga Fernandes
>>
>> University of Massachusetts Dartmouth
>> 200 Mill Road - Fairhaven, MA
>> Tel: (508) 910-6381
>> Email: falvarengafernan...@umassd.edu
>>  ocef...@yahoo.com.br
>>  ocef...@gmail.com
>>
>> http://ocefpaf.tiddlyspot.com/
>> *
>>
>>
>> --
>> The Planet: dedicated and managed hosting, cloud storage, colocation
>> Stay online with enterprise data centers and the best network in the
>> business
>> Choose flexible plans and management services without long-term contracts
>> Personal 24x7 support from experience hosting pros just a phone call away.
>> http://p.sf.net/sfu/theplanet-com
>> ___
>> Matplotlib-users mailing list
>> Matplotlib-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
>>
>
>
> --
> Stephane Raynaud
>
--
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] MatPlotLib Usage FAQ Page Needs Some Work.

2010-02-08 Thread Alan G Isaac
On 2/6/2010 2:35 PM, Wayne Watson wrote:
> I'm not even sure if we are  pro-pylab or  pyplot as the preferred-style.

It is somewhat personal preference:
do you want access to NumPy and pyplot functions
in a single name space or not. But the "preferred"
style is the most explicit:
http://matplotlib.sourceforge.net/faq/usage_faq.html

Alan Isaac
(just another user...)

--
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Surface Plot

2010-02-08 Thread Ted Kord
Hi

I'd like to generate a surface plot using mplot3d. However, Z is not a
function of X and/or Y. It's just a set of scalar values. So, the following
doesn't work:

X = np.arange(2, 102, 2)
Y = np.arange(0, 15.15, 0.15)
X, Y = np.meshgrid(X, Y)
Z = f[2]
ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.jet)

Is there a way that I can do this?

Thank you.

Ted
--
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Python Matplotlib: How to close a plot?

2010-02-08 Thread JackD

Hi there!
I need to know how to close a figure/chart in matplot. 
The problem is: I am developing a program that calculates >5 figures and
needs some minutes to calculate one. So it would be great if I could close
the figure if the next figure is ready cause then I am able to show both
figures and so on.

Does anyone know how it works and could you explain on the below example?



import matplotlib.pyplot as plt
import time

fig = plt.figure(1)
ax = fig.add_subplot(111)
ax.plot((1, 3, 1))
plt.draw()

fig = plt.figure(2)
ax = fig.add_subplot(111)
ax.plot((4, 1, 0))


plt.show()

time.sleep(10)

plt.close(1)
-- 
View this message in context: 
http://old.nabble.com/Python-Matplotlib%3A-How-to-close-a-plot--tp27485059p27485059.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Memory leak when destroying Tk frame containing a figure

2010-02-08 Thread Maximilian Mauer
 Hello! I'm writing an application that will show different plots on it's GUI. In order to switch between the different plot types I'd like to destroy the first plot and to create a new afterwards. I stumbled into a memory leak since I don't know how to close matplotlib figures the clean way. I wrote a small test programm. Pressing the button 'create' creates a figure and 'delete' should destroy it. Since the graph class is derived from the Tix.Frame class I would expect that destroying the Frame would also remove all matplot stuff. But when I do not implement my own destroy() method in the graph class, destroying the Frame shows absolutely no effect. The plot simply stays on the screen. When I overload the Tix.Frame.destroy() method with my own implementation, as shown below, the plot disappears but not all memory is being released. When creating and deleting figures, the amount of memory python needs is constantly growing and python eventually crashes. I tried to find a solution on the internet but I found nothing really helpful so far. All examples I found just display something and then just exit. I appreciate any help! -- import matplotlib matplotlib.use('TkAgg') from numpy import arange, sin, pi from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2TkAgg from matplotlib.figure import Figure import Tix  import sys def destroy(e): sys.exit() root = Tix.Tk() class graph(Tix.Frame):     def __init__(self, master, **kw):         Tix.Frame.__init__(self, master, **kw)         self.f = Figure(figsize=(5,4), dpi=100)         self.a = self.f.add_subplot(111)         t = arange(0.0,3.0,0.01)         s = sin(2*pi*t)         self.a.plot(t,s)         self.canvas = FigureCanvasTkAgg(self.f, master=self.master)         self.canvas.show()         self.canvas.get_tk_widget().pack(side=Tix.TOP, fill=Tix.BOTH, expand=1)         self.toolbar = NavigationToolbar2TkAgg(self.canvas, root )         self.toolbar.update()         self.canvas._tkcanvas.pack(side=Tix.TOP, fill=Tix.BOTH, expand=1)              def destroy(self):         Tix.Frame.destroy(self)         self.toolbar.destroy()         self.canvas._tkcanvas.destroy()                   class ui(Tix.Frame):          g = None          def __init__(self, master, **kw):         Tix.Frame.__init__(self, master, **kw)                  self.b = Tix.Button(self, text='create', command=self.create)         self.b.pack()                  self.b2 = Tix.Button(self, text='delete', command=self.delete)         self.b2.pack()     def delete(self):         try:             self.g.destroy()         except:             pass              def create(self):         self.delete()         self.g = graph(root)                      ui(root).pack() root.mainloop()  GRATIS für alle WEB.DE-Nutzer: Die maxdome Movie-FLAT!   Jetzt freischalten unter http://movieflat.web.de


--
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] how to make an axis labels visible in axes_grid?

2010-02-08 Thread Jae-Joon Lee
axes_grid uses a custome axes class. See

http://matplotlib.sourceforge.net/mpl_toolkits/axes_grid/users/overview.html#axisline

For more details, see

http://matplotlib.sourceforge.net/mpl_toolkits/axes_grid/users/axislines.html

To make ticklabel visible, you may do

 grid.axes_all[1].axis["bottom"].major_ticklabels.set_visible(True)

However, AxesGrid takes an *ngrids* parameter which controls the
number of grids. So, in your example,

f = plt.figure()
grid = axes_grid.AxesGrid(f, 111, nrows_ncols=(2,2), ngrids=3)

(no manual adding of grids. also top-right axes will have x-ticklabels
by default).

Regards,

-JJ





On Mon, Feb 8, 2010 at 7:09 AM, Ernest Adrogué  wrote:
> Hi,
>
> I have an AxesGrid instance of 2x2 subplots. I actually only
> want 3 subplots, so I instantiate AxesGrid with the add_all=False
> option, and manually add only the first 3 axes to the figure:
>
> import matplotlib as plt
> from mpl_toolkits import axes_grid
>
> f = plt.figure()
> grid = axes_grid.AxesGrid(f, 111, nrows_ncols=(2,2), add_all=False)
> f.add_axes(grid.axes_all[0])
> f.add_axes(grid.axes_all[1])
> f.add_axes(grid.axes_all[2])
>
>
> Now, the problem seems to be that the top right subplot doesn't
> have visible labels on the x axis, and I can't figure out how to
> add them. Any idea of how it can be done??
>
> Thanks.
>
> Ernest
>
> --
> The Planet: dedicated and managed hosting, cloud storage, colocation
> Stay online with enterprise data centers and the best network in the business
> Choose flexible plans and management services without long-term contracts
> Personal 24x7 support from experience hosting pros just a phone call away.
> http://p.sf.net/sfu/theplanet-com
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>

--
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] quiver + dates

2010-02-08 Thread Stephane Raynaud
Hi Filipe,

you can fist use the quiver() function in the classic way for stick plots,
then use gca().xaxis_date().

Here is a simple example :

import pylab as P
# t may be generated using date2num()
t = P.arange(100,110,.1)
u = P.sin(t)
v = P.cos(t)
P.quiver([t],[[0]*len(t)],u,v)
P.gca().xaxis_date()
P.show()


On Sun, Feb 7, 2010 at 6:11 PM, Filipe Pires Alvarenga Fernandes <
ocef...@gmail.com> wrote:

> Hello list,
>
> I'm trying to create a stick-plot figure using the quiver function from
> matplotlib. However, I'm failing miserably to plot dates in the x-axis. Has
> anyone done this before? Also, is there an effort to create a stickplot
> function?
>
> Thanks, Filipe
>
> *
> Filipe Pires Alvarenga Fernandes
>
> University of Massachusetts Dartmouth
> 200 Mill Road - Fairhaven, MA
> Tel: (508) 910-6381
> Email: falvarengafernan...@umassd.edu
>  ocef...@yahoo.com.br
>  ocef...@gmail.com
>
> http://ocefpaf.tiddlyspot.com/
> *
>
>
> --
> The Planet: dedicated and managed hosting, cloud storage, colocation
> Stay online with enterprise data centers and the best network in the
> business
> Choose flexible plans and management services without long-term contracts
> Personal 24x7 support from experience hosting pros just a phone call away.
> http://p.sf.net/sfu/theplanet-com
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>


-- 
Stephane Raynaud
--
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] how to make an axis labels visible in axes_grid?

2010-02-08 Thread Ernest Adrogué
Hi,

I have an AxesGrid instance of 2x2 subplots. I actually only
want 3 subplots, so I instantiate AxesGrid with the add_all=False
option, and manually add only the first 3 axes to the figure:

import matplotlib as plt
from mpl_toolkits import axes_grid

f = plt.figure()
grid = axes_grid.AxesGrid(f, 111, nrows_ncols=(2,2), add_all=False)
f.add_axes(grid.axes_all[0])
f.add_axes(grid.axes_all[1])
f.add_axes(grid.axes_all[2])


Now, the problem seems to be that the top right subplot doesn't
have visible labels on the x axis, and I can't figure out how to
add them. Any idea of how it can be done??

Thanks.

Ernest

--
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Text not showing up when I save a figure as EPS

2010-02-08 Thread Cédrick FAURY
Hello,

When I save the figure as EPS, no text shows up.
The problem occurs with the example "embedding_in_wx2.py" and when I use 
MSWord to show the eps file.

Is it a problem with MSWord ??

Thanks by advance.
Cédrick

--
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Axes3D - Equal Aspect Ratio

2010-02-08 Thread Paul Wellner Bou
Hi,

I am searching for a solution of the axis aspect in 3d plots, too.

On 10/14/2009 14:01, Tinne De Laet wrote:
>
> axis("scaled")
> worked for me.
>
> Tinne

This does not seem to work. At least I am not getting it to work. This 
command does not seem to be applied to the 3d axis. Do you have an 
example where this works on 3d axis?

Regards
Paul.

--
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users