problem with dynamic subplots and wx

Hello,

I just upgraded a number of things on my Mac OS X (Tiger) machine, including to the latest version of wx and matplotlib. I found that there is a bug in the display of dynamic plots with subplots. If I change the subplot line in the examples/dynamic_demo_wx.py to:

a = self.fig.add_subplot(221)

instead of

a = self.fig.add_subplot(111)

the plot never shows. It works for 111, and for 121, but not 221. Not sure why! It works in interactive mode, in ipython, but not in dynamic plot.

Any ideas?

	thanks,

		Brian Blais
···

Brian Blais

bblais@…1129…

http://web.bryant.edu/~bblais

I am posting here the minimal program that reproduces the problem, based on a modified embedded_in_wx.py. The axis shows up, and has the right limits, but no plot forms in the axis. Weird!

		bb
···

On Apr 23, 2008, at Apr 23:4:33 PM, Brian Blais wrote:

I just upgraded a number of things on my Mac OS X (Tiger) machine, including to the latest version of wx and matplotlib. I found that there is a bug in the display of dynamic plots with subplots. If I change the subplot line in the examples/dynamic_demo_wx.py to:

a = self.fig.add_subplot(221)

instead of

a = self.fig.add_subplot(111)

the plot never shows. It works for 111, and for 121, but not 221. Not sure why! It works in interactive mode, in ipython, but not in dynamic plot.

Brian Blais

bblais@…1129…

http://web.bryant.edu/~bblais

#!/usr/bin/env python

from matplotlib.backends.backend_wx import FigureCanvasWx,FigureManager

from matplotlib.figure import Figure

import numpy

from wx import *

class PlotFigure(Frame):

def init(self):

Frame.init(self, None, -1, “Test embedded wxFigure”)

self.fig = Figure((9,8), 75)

self.canvas = FigureCanvasWx(self, -1, self.fig)

Create a figure manager to manage things

self.figmgr = FigureManager(self.canvas, 1, self)

Now put all into a sizer

sizer = BoxSizer(VERTICAL)

This way of adding to sizer allows resizing

sizer.Add(self.canvas, 1, LEFT|TOP|GROW)

self.SetSizer(sizer)

self.Fit()

def plot_data(self):

a = self.fig.add_subplot(111) # this works

a = self.fig.add_subplot(221) # this doesn’t work

t = numpy.arange(0.0,3.0,0.01)

s = numpy.sin(2numpy.pit)

a.plot(t,s)

if name == ‘main’:

app = PySimpleApp(0)

frame = PlotFigure()

frame.plot_data()

frame.Show()

app.MainLoop()

In the quest to discover the problem, I found that the problem exists in svn (version .98pre) but not in .91.2. Both with version wx-2.8.7.1.

		bb
···

On Apr 23, 2008, at Apr 23:6:56 PM, Brian Blais wrote:

On Apr 23, 2008, at Apr 23:4:33 PM, Brian Blais wrote:

I just upgraded a number of things on my Mac OS X (Tiger) machine, including to the latest version of wx and matplotlib. I found that there is a bug in the display of dynamic plots with subplots. If I change the subplot line in the examples/dynamic_demo_wx.py to:

a = self.fig.add_subplot(221)

instead of

a = self.fig.add_subplot(111)

the plot never shows.

Brian Blais

bblais@…1129…

http://web.bryant.edu/~bblais

I'm using SVN matplotlib and wxPython 2.8.7.1, and I'm not running
into the problem. Though I may be interpreting your problem
incorrectly. I've attached a screen capture of the window that opens
up when I run your program.

Josh

221.tiff (27.9 KB)

···

On Wed, Apr 23, 2008 at 5:33 PM, Brian Blais <bblais@...1129...> wrote:

On Apr 23, 2008, at Apr 23:6:56 PM, Brian Blais wrote:

On Apr 23, 2008, at Apr 23:4:33 PM, Brian Blais wrote:

I just upgraded a number of things on my Mac OS X (Tiger) machine, including
to the latest version of wx and matplotlib. I found that there is a bug in
the display of dynamic plots with subplots. If I change the subplot line in
the examples/dynamic_demo_wx.py to:

        a = self.fig.add_subplot(221)

instead of

        a = self.fig.add_subplot(111)

the plot never shows.

In the quest to discover the problem, I found that the problem exists in svn
(version .98pre) but not in .91.2. Both with version wx-2.8.7.1.

bb

--
Brian Blais
bblais@...1129...
bblais on the web

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.

http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

I should note that I'm doing this on OS X 10.5.2, but I don't imagine
Tiger would have a problem Leopard doesn't have.

Josh

···

On Wed, Apr 23, 2008 at 6:16 PM, Joshua Lippai <discerptor@...287...> wrote:

I'm using SVN matplotlib and wxPython 2.8.7.1, and I'm not running
into the problem. Though I may be interpreting your problem
incorrectly. I've attached a screen capture of the window that opens
up when I run your program.

Josh

On Wed, Apr 23, 2008 at 5:33 PM, Brian Blais <bblais@...1129...> wrote:
>
>
> On Apr 23, 2008, at Apr 23:6:56 PM, Brian Blais wrote:
>
> On Apr 23, 2008, at Apr 23:4:33 PM, Brian Blais wrote:
>
> I just upgraded a number of things on my Mac OS X (Tiger) machine, including
> to the latest version of wx and matplotlib. I found that there is a bug in
> the display of dynamic plots with subplots. If I change the subplot line in
> the examples/dynamic_demo_wx.py to:
>
>
> a = self.fig.add_subplot(221)
>
> instead of
>
>
> a = self.fig.add_subplot(111)
>
> the plot never shows.
>
>
> In the quest to discover the problem, I found that the problem exists in svn
> (version .98pre) but not in .91.2. Both with version wx-2.8.7.1.
>
>
>
>
> bb
>
>
>
> --
> Brian Blais
> bblais@...1129...
> bblais on the web
>
>
>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
> Don't miss this year's exciting event. There's still time to save $100.
> Use priority code J8TL2D2.
>
> http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> matplotlib-users List Signup and Options
>
>

you do indeed have the problem. If you change the subplot(211) to subplot(111) you’ll see the proper plot (a sine wave). For some reason, when you try to subplot with 2 rows and 2 columns (and probably more) the line doesn’t appear on the plot. what it should look like, and does with .91.2, is attached.

	bb

working.tiff (32.7 KB)

···

On Apr 23, 2008, at Apr 23:9:17 PM, Joshua Lippai wrote:

I should note that I’m doing this on OS X 10.5.2, but I don’t imagine

Tiger would have a problem Leopard doesn’t have.

Brian Blais

bblais@…1129…

http://web.bryant.edu/~bblais

The clipping rectangle was using inverted y-coordinates (origin at bottom), rather than origin at top. This has been fixed in SVN trunk r5067.

FWIW, this seems to be specific to the Wx rendering backend, and doesn't happen with Agg, Gtk, Cairo etc.

Cheers,
Mike

Brian Blais wrote:

···

On Apr 23, 2008, at Apr 23:9:17 PM, Joshua Lippai wrote:

I should note that I'm doing this on OS X 10.5.2, but I don't imagine
Tiger would have a problem Leopard doesn't have.

you do indeed have the problem. If you change the subplot(211) to subplot(111) you'll see the proper plot (a sine wave). For some reason, when you try to subplot with 2 rows and 2 columns (and probably more) the line doesn't appear on the plot. what it should look like, and does with .91.2, is attached.

bb

--
Brian Blais
bblais@...1129... <mailto:bblais@…1129…>
bblais on the web <http://web.bryant.edu/~bblais&gt;

------------------------------------------------------------------------

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
------------------------------------------------------------------------

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options
  
--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA