Ticket #26 (closed defect: fixed)

Opened 10 months ago

Last modified 4 months ago

plot() missbehaviour short inputs

Reported by: anonymous Assigned to:
Priority: moderate Keywords:
Cc:

Description

plot() generates wrong plots for short inputs. For example try the following code:

space = range(10, 15)
plot(space)

In the resulting plot the y-axis scales from 0.0 to -4.0.

Attachments

0001-Use-add_subplot-instead-of-add_axes-because-it-uses.patch (0.9 kB) - added by kaiw on 06/15/08 11:35:06.
Patch

Change History

03/13/08 10:23:22 changed by kaiw

Actually, the axis scale is correct, but incorrectly displayed. It just looks a bit like -0.0 to -4.0 because the leftmost character (the 1) gets cut off. Easily verified by checking the above for range(1000,1500).

It looks like PlotWidget? leaves a fixed amount of space for axes, so when the stub labels are too long, they just get truncated.

06/15/08 11:35:06 changed by kaiw

  • attachment 0001-Use-add_subplot-instead-of-add_axes-because-it-uses.patch added.

Patch

06/15/08 11:47:34 changed by kaiw

The above patch just uses the recommended method of adding a subplot instead of manually creating the axes, as the default behaviour of add_subplot uses margins that are wide enough to show all tic labels up to the point where it switches over to using scientific notation. This behaviour can be tested with:

from replot import *

space = range(10, 15)
plot(space)

space = range(0, 1000000, 10000)
plot(space)

space = range(0, 10000000, 100000)
plot(space)

It's still quite fragile, however; a long axis tic label can easily push the y-axis label off the left side.

08/10/08 21:04:54 changed by otaylor

  • status changed from new to closed.
  • resolution set to fixed.

Applied. Thanks!

http://git.fishsoup.net/cgit/reinteract/commit/?id=236d5e6c009d7c0f3c9a7070b2f02b334a4d6693

I'm not too happy now that all most graphs are smaller and have lots of space around, but probably better than having the labels cut off.