bug?

Hi: The following script:

    > #!/usr/bin/env python from matplotlib.matlab import *

    > figure(1) plot([0],[0]) show()

Thanks, Peter, for alerting me to this problem. I'm now adding this
script and several other instances of plotting constants in a variety
of guises to the unit testing scripts. I think the following fix will
work for you. Replace matplotlib.axes.Axes.add_line with

    def add_line(self, l):
        "Add a line to the list of plot lines"
        self._set_artist_props(l)
        
        xdata = l.get_xdata()
        ydata = l.get_ydata()
        if l.get_transform() != self.transData:
            xys = self._get_verts_in_data_coords(
                l.get_transform(), zip(xdata, ydata))
            self.update_datalim(xys)
        else:
            # the data are already using the data coord system - no
            # transforms necessary
            minx, maxx = min(xdata), max(xdata)
            miny, maxy = min(ydata), max(ydata)
            if minx==maxx:
                minx -= 1
                maxx += 1

            if miny==maxy:
                miny -= 1
                maxy += 1
                
            corners = ( (minx, miny), (maxx, maxy) )

            self.update_datalim(corners)

        l.set_clip_box(self.bbox)
        self._lines.append(l)

Passes my tests...

JDH

We are trying to have setup.py handle X11-based Tkinter on Mac OS X
(to date that is the only Tkinter we use). Does anyone out there
use Tkagg with the Aqua-based Tkinter on Mac OS X? We are unclear
as to whether the Aqua version is really useful yet.

Thanks, Perry Greenfield

Perry Greenfield wrote:

We are trying to have setup.py handle X11-based Tkinter on Mac OS X
(to date that is the only Tkinter we use). Does anyone out there
use Tkagg with the Aqua-based Tkinter on Mac OS X? We are unclear
as to whether the Aqua version is really useful yet.

TkAgg with Aqua-based Tkinter works for me on Mac OS X. (That's
with matplotlib 0.54 -- I haven't tried the latest CVS with fixes
for dynamic updates, but am happy to hear it will be faster!).

The Aqua-based Tkinter is not great, and I would be perfectly happy
using X11-based Tkinter. I simply installed the Tkinter with the
MacPython and its PackageManager. Is X11-based Tkinter available in
such a package, or does it require a source build?? A source build
would be OK with me, but might make it difficult to distribute apps.

--Matt Newville <newville @ cars.uchicago.edu>

Matt Newville wrote:

Perry Greenfield wrote:

We are trying to have setup.py handle X11-based Tkinter on Mac OS X
(to date that is the only Tkinter we use). Does anyone out there
use Tkagg with the Aqua-based Tkinter on Mac OS X? We are unclear
as to whether the Aqua version is really useful yet.
   
It's been a little while since I've gotten down-and-dirty on OS X, but as of a year or so ago, I was continually frustrated with Tkinter on OS X because of apparent weird little bugs, but I never felt sufficiently on top of Tkinter to really believe they were bugs with Tkinter or with me. Anyhow, I switched to wx, and have never been happier. It looks great on Aqua, is totally cross-platform, and XRCed rocks!

TkAgg with Aqua-based Tkinter works for me on Mac OS X. (That's
with matplotlib 0.54 -- I haven't tried the latest CVS with fixes
for dynamic updates, but am happy to hear it will be faster!).

The Aqua-based Tkinter is not great, and I would be perfectly happy
using X11-based Tkinter. I simply installed the Tkinter with the
MacPython and its PackageManager. Is X11-based Tkinter available in
such a package, or does it require a source build?? A source build
would be OK with me, but might make it difficult to distribute apps.

Fink sticks to the X environment, so I'm 99% sure that if you install their Tkinter it'll run on X11. I think this probably means installing Python from fink, too. So you'd have 2 Pythons: Apple's and fink's (in /sw/bin/python, I guess). If you want to distribute apps as a packaged .dmg that someone can just download and run on an OS X system, the fink route seems a little, uh, challenging.

Good luck!
Andrew

John Hunter wrote:

"Peter" == Peter Groszkowski <pgroszko@...84...> writes:

   > Hi: The following script:

   > #!/usr/bin/env python from matplotlib.matlab import *

   > figure(1) plot([0],[0]) show()

Thanks, Peter, for alerting me to this problem. I'm now adding this
script and several other instances of plotting constants in a variety
of guises to the unit testing scripts. I think the following fix will
work for you. Replace matplotlib.axes.Axes.add_line with

   def add_line(self, l):
       "Add a line to the list of plot lines"
       self._set_artist_props(l)
              xdata = l.get_xdata()
       ydata = l.get_ydata()
       if l.get_transform() != self.transData:
           xys = self._get_verts_in_data_coords(
               l.get_transform(), zip(xdata, ydata))
           self.update_datalim(xys)
       else:
           # the data are already using the data coord system - no
           # transforms necessary
           minx, maxx = min(xdata), max(xdata)
           miny, maxy = min(ydata), max(ydata)
           if minx==maxx:
               minx -= 1
               maxx += 1

           if miny==maxy:
               miny -= 1
               maxy += 1
                          corners = ( (minx, miny), (maxx, maxy) )

           self.update_datalim(corners)

       l.set_clip_box(self.bbox)
       self._lines.append(l)

Passes my tests...

Just a note that the version of the above method in 0.54.1 still gives me:

Traceback (most recent call last):
  File "/usr/lib/python2.2/site-packages/matplotlib/backends/backend_gtkagg.py", line 75, in callback
    self.draw()
  File "/usr/lib/python2.2/site-packages/matplotlib/backends/backend_gtkagg.py", line 42, in draw
    agg.draw()
  File "/usr/lib/python2.2/site-packages/matplotlib/backends/backend_agg.py", line 296, in draw
    self.figure.draw(self.renderer)
  File "/usr/lib/python2.2/site-packages/matplotlib/figure.py", line 130, in draw
    for a in self.axes: a.draw(renderer)
  File "/usr/lib/python2.2/site-packages/matplotlib/axes.py", line 607, in draw
    self.xaxis.draw(renderer)
  File "/usr/lib/python2.2/site-packages/matplotlib/axis.py", line 463, in draw
    tick.draw(renderer)
  File "/usr/lib/python2.2/site-packages/matplotlib/axis.py", line 130, in draw
    if self.label1On: self.label1.draw(renderer)
  File "/usr/lib/python2.2/site-packages/matplotlib/text.py", line 209, in draw
    ismath=self.is_math_text())
  File "/usr/lib/python2.2/site-packages/matplotlib/backends/backend_agg.py", line 200, in draw_text
    self._renderer.draw_text(
OverflowError: float too large to convert

When doint plot([0],[0]).
The above substitute fixes the problem though...

···

--
Peter Groszkowski Gemini Observatory
Tel: +1 808 974-2509 670 N. A'ohoku Place
Fax: +1 808 935-9235 Hilo, Hawai'i 96720, USA