ValueError in backend_gtk.py when switching from linear to log scale

Hi there,

I'm using matplotlib version 0.98.3 and I'm switching the scale
between linear and log in my application.
This worked with matplotlib 0.91.3.

I get the following error:

embedding_in_gtk2.py (929 Bytes)

···

-------------
Traceback (most recent call last):
  File "/usr/lib64/python2.5/site-packages/matplotlib/backends/backend_gtk.py", line 333, in expose_event
    self._render_figure(self._pixmap, w, h)
  File "/usr/lib64/python2.5/site-packages/matplotlib/backends/backend_gtk.py", line 321, in _render_figure
    self.figure.draw (self._renderer)
  File "/usr/lib64/python2.5/site-packages/matplotlib/figure.py", line 759, in draw
    for a in self.axes: a.draw(renderer)
  File "/usr/lib64/python2.5/site-packages/matplotlib/axes.py", line 1523, in draw
    a.draw(renderer)
  File "/usr/lib64/python2.5/site-packages/matplotlib/axis.py", line 718, in draw
    tick.draw(renderer)
  File "/usr/lib64/python2.5/site-packages/matplotlib/axis.py", line 193, in draw
    self.label1.draw(renderer)
  File "/usr/lib64/python2.5/site-packages/matplotlib/text.py", line 771, in draw
    Text.draw(self, renderer)
  File "/usr/lib64/python2.5/site-packages/matplotlib/text.py", line 329, in draw
    ismath=self.is_math_text(line))
  File "/usr/lib64/python2.5/site-packages/matplotlib/backends/backend_gdk.py", line 150, in draw_text
    self._draw_mathtext(gc, x, y, s, prop, angle)
  File "/usr/lib64/python2.5/site-packages/matplotlib/backends/backend_gdk.py", line 195, in _draw_mathtext
    array[:,:,3]=Xs
ValueError: shape mismatch: objects cannot be broadcast to a single shape
--------------

I've attached a modified example file to reproduce the error.

Any clue what's wrong with set_xscale('log'), set_yscale('log')

Regards
Werner

Can you provide a standalone script to illustrate this problem?

I suspect that the position of the text is somehow negative and is getting masked away by the log transformation (which is obviously undefined for negative numbers).

Also, have you tried the GtkAgg backend instead? That sees a lot more usage, and therefore may not contain this bug.

That said, this case should be handled correctly and probably requires a check. I'm away from the office and won't be able to look into this further until next week.

Cheers,
Mike

Hi Mike,

Can you provide a standalone script to illustrate this problem?

Already provided in the last mail. I've added a second one where you can
switch between gtk and gtkagg backend.

I suspect that the position of the text is somehow negative and is
getting masked away by the log transformation (which is obviously
undefined for negative numbers).

There are no negative numbers in the example.
the gtk backend still doesn't work.

Also, have you tried the GtkAgg backend instead? That sees a lot
more usage, and therefore may not contain this bug.

Just tried gtkagg and it works fine. It even guesses a good minimal
value for the log range if the plot has negative data. I will switch to
that backend in my application.

That said, this case should be handled correctly and probably
requires a check.

Regards
Werner

matplotlib_logscale.py (1 KB)

···

On Freitag, 22. August 2008, Michael Droettboom wrote: