[ANN] wxPyPlot V1.1 Beta 1

Hi All,

I have released Version 1.1 beta 1 of wxPyPlot for producing simple plots
in wxPython.

This release adds a method for saving plots as various types
of picture files. The variables have been changed from class to instance
variables so more than one plot window can be used in an application.
Instructions and files are now provided to use wxPyPlot as a plug-in in Boa,
if desired.

Users will require wxPython 2.4.0.6 or later and Numeric.

For your viewing pleasure, the website now has some html docs as well as a
few more screen shots of things. Check out:
http://www.cyberus.ca/~g_will/wxPython/wxpyplot.html

Comments and suggestions welcome.

Regards,

Gordon Williams

···

-------------------------------------------------------------
What is wxPyPlot??

wxPyPlot is an enhanced derivative version of wxPlotCanvas to provide simple
lightweight plotting in wxPython. The emphasis is both on simple and
lightweight.

Before starting this work I looked at two plotting packages that could be
adapted to work with wxPython. SciPy Plt and Chaco are sophisticated and
powerful, but at the expense of consuming huge amounts of computer resources
for simple plots. They can be found at http://scipy.com. I was looking for
something that could be incorporated into a Boa application and had the
ability to plot lines with large numbers of points quickly for data capture
applications. wxPlotCanvas had the speed and some of the functionality that
I was looking for, but lacked a lot of features that I needed. This effort
has filled the gap.

Features:
- Automatic Scaling of Axes
- Legends for lines and markers
- Plot Title and Axis Labels
- Zoom Region with Mouse (Rubber Band) or Programmatically
- Scroll Up/Down, Left/Right
- Plot Grid (Graticule) on Graph
- Printing, Preview, and Page Set-up (margins) -WYSIWYG
- Save Plot using various Picture Formats
- Cursor X-Y User Axis Values
- Simple, Lightweight and Fast
- Can be Used with Boa Applications if Desired
- Lots of Comments and Doc Strings along with Example Usage

I have tested this out on Windows using Python 2.2 and wxPython 2.4.0.6. If
you have the chance to test it on Linux, please let me know how it works.
Suggestions and improvements welcome.

Screen shots, source and instructions for Boa can be found at

http://www.cyberus.ca/~g_will/wxPython/wxpyplot.html

Gordon Williams wrote:

I have released Version 1.1 beta 1 of wxPyPlot for producing simple plots
in wxPython.

It's looking good Gordon. Unfortunately, printing doesn't work under
linux. I discoverd this in your last version, but never finished my
testing, so never told you about it. The problem is that wxPostscriptDC
has no Clear() method.

Putting a try: except: around the Clear() call in PlotCanvas.Draw()
works:

        try:
            dc.Clear()
        except wxc.wxPyAssertionError:
            # This is probably because dc is a wxPostscriptdc,
            # or another one that doesn't have a Clear() method
            pass

and you also have to add wxc to the import line:

from wxPython import wx, wxc

I'm not sure if that will cause any other problems. None for me so far,
but I have barely tested it. I suppose it would be better to explicitly
test for a PostscriptDC, but I wasn't sure how to do that off the top of
my head. The other option would be to have a separate PlotCanvas.Clear()
call, rather than including it in PlotCanvas.Draw(). In any case, this
works.

Also:

fillstyle= wx.wxCROSSDIAG_HATCH

Doesn't appear to work with the PostscriptDC, but I don't imagine there
is anything to be done about that (at least at the Python level)

Thanks for maintaining this,

-CHris

···

--
Christopher Barker, Ph.D.
Oceanographer
                                        
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

Chris Barker wrote:

Putting a try: except: around the Clear() call in PlotCanvas.Draw()
works:

        try:
            dc.Clear()
        except wxc.wxPyAssertionError:
            # This is probably because dc is a wxPostscriptdc,
            # or another one that doesn't have a Clear() method
            pass

and you also have to add wxc to the import line:

from wxPython import wx, wxc

There should be a reference to wxPyAssertionError in the wxPython.wx module. No need to expllicitly import wxc.

I'm not sure if that will cause any other problems. None for me so far,
but I have barely tested it. I suppose it would be better to explicitly
test for a PostscriptDC, but I wasn't sure how to do that off the top of
my head.

dc.GetClassName() # returns the name of the wxWidnows class

dc.__class__.__name__ # the name of the Python class

if isinstance(dc, wxPostscriptDCPtr):
  ...

The other option would be to have a separate PlotCanvas.Clear()

call, rather than including it in PlotCanvas.Draw(). In any case, this
works.

Also:

fillstyle= wx.wxCROSSDIAG_HATCH

Doesn't appear to work with the PostscriptDC, but I don't imagine there
is anything to be done about that (at least at the Python level)

No. It would have to be fixed in the C++ class.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Hi,

wxPostscriptdc derives from a wxDC. Therefore, there should be a Clear
method.

Am I missing something or is this a bug (wxPython or wxWindows)?

If it is a bug, can it be fixed in relatively short order so I don't have to
clutter the code with hacks.

Regards,

Gordon Williams

···

----- Original Message -----
From: "Chris Barker" <Chris.Barker@noaa.gov>
To: <wxPython-users@lists.wxwindows.org>; "Gordon Williams"
<g_will@cyberus.ca>
Sent: Tuesday, June 03, 2003 2:54 PM
Subject: Re: [wxPython-users] [ANN] wxPyPlot V1.1 Beta 1

Putting a try: except: around the Clear() call in PlotCanvas.Draw()
works:

        try:
            dc.Clear()
        except wxc.wxPyAssertionError:
            # This is probably because dc is a wxPostscriptdc,
            # or another one that doesn't have a Clear() method
            pass

Gordon Williams wrote:

Hi,

wxPostscriptdc derives from a wxDC. Therefore, there should be a Clear
method.

Am I missing something or is this a bug (wxPython or wxWindows)?

If it is a bug, can it be fixed in relatively short order so I don't have to
clutter the code with hacks.

It has one, but it has a wxFAIL_MSG("not implemented") which gets turned into an exception by wxPython.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Gordon Williams wrote:

wxPostscriptdc derives from a wxDC. Therefore, there should be a Clear
method.

Am I missing something or is this a bug (wxPython or wxWindows)?

Robin Dunn wrote:

It has one, but it has a wxFAIL_MSG("not implemented") which gets turned
into an exception by wxPython.

I imagine the issue here is that you can't really Clear a postscript
file, which is what that DC is creating. However, It makes me wonder how
other printer-type DCs work.

A note to wx-dev would probably get you an explaination of why it was
done this way.

Gordon Williams wrote:

If it is a bug, can it be fixed in relatively short order so I don't have to
clutter the code with hacks.

Fortunately, you've got the code nicely structured, so that this
particular hack only needs to be put in one place.

-Chris

···

--
Christopher Barker, Ph.D.
Oceanographer
                                        
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov