Buglets in svg backend?

Hi folks,

I've just implemented support in ipython for simultaneous use of the
interactive mpl gui backends along with inlined figures, as I had
suggested to Eric things could work.

But I'm seeing two little glitches, illustrated here:

http://fperez.org/tmp/mpl_svg_bug.png

The white console on the right is IPython, the mpl window was my only
open figure.

The code I ran was:

x=rand(1000)
plot (x) # this pops up the normal gui, I tested Qt4Agg and GTKAgg

paste() # this pasted the open figure into the IPython console.

At this point, the plot in the window got that funny size, with the
x-labels double-drawn. It seems as if the figure got re-drawn over
the previous canvas, at a different size. If I resize the window, the
problem goes away, but if I don't resize it, it persists through new
plot/draw operations.

The second problem... I then zoomed the interactive window and issued
paste again, getting the plot in the bottom right of the figure:
paste()

And here the bug seems to be related to clipping: while the window
clips OK, the SVG seems not to.

Is this a fundamental limitation of the SVG backend?

For IPython we can also switch to pngs if that turns out to work
better, but I figured I'd report these...

All this was done with current mpl from trunk.

Cheers,

f

Howdy,

I just wanted to bump this again: given the speed of Michael's recent
SVG fixes, maybe fixing these two is also quite easy. They are the
only problem coming from matplotlib right now regarding the use of the
new qt console for ipython.

If not let me know and I'll just file reports on the tracker for
long-term storage :slight_smile:

Cheers,

f

···

On Tue, Sep 7, 2010 at 3:39 AM, Fernando Perez <fperez.net@...149...> wrote:

Hi folks,

I've just implemented support in ipython for simultaneous use of the
interactive mpl gui backends along with inlined figures, as I had
suggested to Eric things could work.

But I'm seeing two little glitches, illustrated here:

http://fperez.org/tmp/mpl_svg_bug.png

The white console on the right is IPython, the mpl window was my only
open figure.

The code I ran was:

x=rand(1000)
plot (x) # this pops up the normal gui, I tested Qt4Agg and GTKAgg

paste() # this pasted the open figure into the IPython console.

At this point, the plot in the window got that funny size, with the
x-labels double-drawn. It seems as if the figure got re-drawn over
the previous canvas, at a different size. If I resize the window, the
problem goes away, but if I don't resize it, it persists through new
plot/draw operations.

The second problem... I then zoomed the interactive window and issued
paste again, getting the plot in the bottom right of the figure:
paste()

And here the bug seems to be related to clipping: while the window
clips OK, the SVG seems not to.

Is this a fundamental limitation of the SVG backend?

For IPython we can also switch to pngs if that turns out to work
better, but I figured I'd report these...

All this was done with current mpl from trunk.

I'm not sure what's causing this. I don't have a Python >= 2.6 environment with all the Qt bells and whistles to test ipython HEAD with (our house standard here is still 2.5)... Once I find the time for that, hopefully I can see what's going on. But I suspect "paste()" is doing something fishy here. Saving an SVG from the standard matplotlib window does not cause the "dpi changing without the window size changing" problem shown here. I would suggest looking at the code triggered from the save dialog in matplotlib and compare it to what "paste()" is doing.

Mike

···

On 09/16/2010 04:54 PM, Fernando Perez wrote:

Howdy,

I just wanted to bump this again: given the speed of Michael's recent
SVG fixes, maybe fixing these two is also quite easy. They are the
only problem coming from matplotlib right now regarding the use of the
new qt console for ipython.

If not let me know and I'll just file reports on the tracker for
long-term storage :slight_smile:

Cheers,

f

On Tue, Sep 7, 2010 at 3:39 AM, Fernando Perez<fperez.net@...149...> wrote:
   

Hi folks,

I've just implemented support in ipython for simultaneous use of the
interactive mpl gui backends along with inlined figures, as I had
suggested to Eric things could work.

But I'm seeing two little glitches, illustrated here:

http://fperez.org/tmp/mpl_svg_bug.png

The white console on the right is IPython, the mpl window was my only
open figure.

The code I ran was:

x=rand(1000)
plot (x) # this pops up the normal gui, I tested Qt4Agg and GTKAgg

paste() # this pasted the open figure into the IPython console.

At this point, the plot in the window got that funny size, with the
x-labels double-drawn. It seems as if the figure got re-drawn over
the previous canvas, at a different size. If I resize the window, the
problem goes away, but if I don't resize it, it persists through new
plot/draw operations.

The second problem... I then zoomed the interactive window and issued
paste again, getting the plot in the bottom right of the figure:
paste()

And here the bug seems to be related to clipping: while the window
clips OK, the SVG seems not to.

Is this a fundamental limitation of the SVG backend?

For IPython we can also switch to pngs if that turns out to work
better, but I figured I'd report these...

All this was done with current mpl from trunk.
     

------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
matplotlib-devel List Signup and Options
   
--
Michael Droettboom
Science Software Branch
Space Telescope Science Institute
Baltimore, Maryland, USA

Here's how to reproduce it in plain python/ipyhon:

from cStringIO import StringIO
plot(rand(100))
canvas = gcf().canvas
string_io = StringIO()
canvas.print_svg(string_io)

Now try panning the figure. Once you pan it and it redraws, the
problem shows up.

This is not seen via a savefig() call, but calling directly print_svg
seems to be the issue. Are we not supposed to use print_svg
ourselves? Should we only use savefig()?

Cheers,

f

···

On Thu, Oct 14, 2010 at 8:15 AM, Michael Droettboom <mdroe@...31...> wrote:

I'm not sure what's causing this. I don't have a Python >= 2.6
environment with all the Qt bells and whistles to test ipython HEAD with
(our house standard here is still 2.5)... Once I find the time for
that, hopefully I can see what's going on. But I suspect "paste()" is
doing something fishy here. Saving an SVG from the standard matplotlib
window does not cause the "dpi changing without the window size
changing" problem shown here. I would suggest looking at the code
triggered from the save dialog in matplotlib and compare it to what
"paste()" is doing.

Yeah -- the print_* format methods should probably be made private. They don't properly save/restore state -- that is all done in one place in the higher-level function "print_figure".

I would suggest:

   canvas.print_figure(string_io, format='svg')

I'll go ahead and make these functions private to avoid confusion -- probably on the trunk only, though, to avoid breaking things for cases where it's currently working "by accident" (i.e. in a non-interactive setting).

Mike

···

On 10/14/2010 02:43 PM, Fernando Perez wrote:

from cStringIO import StringIO
plot(rand(100))
canvas = gcf().canvas
string_io = StringIO()
canvas.print_svg(string_io)
   
--
Michael Droettboom
Science Software Branch
Space Telescope Science Institute
Baltimore, Maryland, USA

Fantastic! You now have your first commit in the IPython repo:

Many thanks! Between this and a better understanding of the png/svg
issues, we're converging on a very solid system.

And all problems I had reported as being from the mpl side are now
resolved, so your debt is cleared :wink:

Regards,

f

···

On Thu, Oct 14, 2010 at 11:55 AM, Michael Droettboom <mdroe@...31...> wrote:

I would suggest:

canvas.print_figure(string_io, format='svg')