re sizing behaviour like in Mircrocal Origin

I integrated mpl into my wxPython application for plotting simple lines.
I would like my canvas to behave differently when the containing window is
being resized.
At the moment all text, all lines, all markers, the legend... remain in the
same state (same size and thickness) regardless whether the plot is small or
big. As a result the plot looks fine at one size only.
I need all elements to be resized with the window just like it happens in
Microcal's scientific plotting software "origin". Everything should resize
as a "whole".
Also, it would be great to keep the aspect ratio of the plot when resizing
and zooming. I could not figure out how to do that. Using methods like
apply_aspect and set_adjustable is not enough.

Is there a way to make those things work?

Thanks,
Jurgen

···

--
View this message in context: http://www.nabble.com/resizing-behaviour-like-in-Mircrocal-Origin-tp14814996p14814996.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

DaFudl wrote:

I integrated mpl into my wxPython application for plotting simple lines.
I would like my canvas to behave differently when the containing window is
being resized.
At the moment all text, all lines, all markers, the legend... remain in the
same state (same size and thickness) regardless whether the plot is small or
big. As a result the plot looks fine at one size only.
I need all elements to be resized with the window just like it happens in
Microcal's scientific plotting software "origin". Everything should resize
as a "whole".

I think what you're asking for would require a pretty major overhaul of matplotlib. The fact that all the text etc. remains the same size is a deliberate design decision, and actually requires a lot more work to make fast enough, since a lot more must be recalculated with each redraw, rather than just multiplying everything by a scale factor.

All that said, you could experiment with rendering to a vector format (e.g. Pdf or Svg) and then have wxPython render it directly with each window resize. (This would be much the same way that resizing a PDF generated by matplotlib in Acrobat Reader scales everything as a whole).

Alternatively, you could try using a backend (e.g. Cairo) that allows you to push a global affine transformation onto the transformation stack. (At present, the Agg backends don't have that functionality -- but it could be added, especially since the recent overhaul of transformations in general in matplotlib.) That way, you could tell the underlying rendering engine (below matplotlib) to scale everything up and down for any subsequent commands it receives from matplotlib.

But, anyway you slice it, I think you're looking at getting your hands dirty in some matplotlib internals. I'm happy to help if you want to work through it, but I don't think I would have time myself.

Also, it would be great to keep the aspect ratio of the plot when resizing
and zooming. I could not figure out how to do that. Using methods like
apply_aspect and set_adjustable is not enough.

That seems to be easy enough to do in the window resize callback -- just programmatically force-resize the window to the desired aspect ratio.

Cheers,
Mike

···

--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA

matplotlib is designed to scale in the way Jurgen requests with DPI
(eg fonts, line thicknesses and the like scale with DPI).

In [65]: fig = figure()

In [66]: plot([1,2,3])
Out[66]: [<matplotlib.lines.Line2D instance at 0xbf965ec>]

In [67]: fig.dpi.set(200)

In [68]: fig.canvas.draw()

with a little work, one could hook into the resize mechanism to
increase the dpi to create the desired effect w/o a major overhaul.
By default what happens is the width and height in inches are changed
with a resize but the dpi is held constant. One could trick
matplotlib by computing a new width, height in inches, and a new dpi
so that the resized canvas width in pixels is the requested size based
on the resize event but the dpi is increased to create the microcal
effect

JDH

···

On Jan 14, 2008 3:55 PM, Michael Droettboom <mdroe@...86...> wrote:

I think what you're asking for would require a pretty major overhaul of
matplotlib. The fact that all the text etc. remains the same size is a

Doh! Why didn't I think of that?

Mike

John Hunter wrote:

···

On Jan 14, 2008 3:55 PM, Michael Droettboom <mdroe@...86...> wrote:

I think what you're asking for would require a pretty major overhaul of
matplotlib. The fact that all the text etc. remains the same size is a

matplotlib is designed to scale in the way Jurgen requests with DPI
(eg fonts, line thicknesses and the like scale with DPI).

In [65]: fig = figure()

In [66]: plot([1,2,3])
Out[66]: [<matplotlib.lines.Line2D instance at 0xbf965ec>]

In [67]: fig.dpi.set(200)

In [68]: fig.canvas.draw()

with a little work, one could hook into the resize mechanism to
increase the dpi to create the desired effect w/o a major overhaul.
By default what happens is the width and height in inches are changed
with a resize but the dpi is held constant. One could trick
matplotlib by computing a new width, height in inches, and a new dpi
so that the resized canvas width in pixels is the requested size based
on the resize event but the dpi is increased to create the microcal
effect

JDH

--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA

Michael Droettboom wrote:

All that said, you could experiment with rendering to a vector format (e.g. Pdf or Svg) and then have wxPython render it directly with each window resize.

If you did want to go that route, someone wrote a SVG renderer for wxPython -- search the wxpython-users list to find it.

I do question why you want this -- MPLs current behavior generally makes the most sense -- you generally want the same font sizes and line thicknesses in a GUI app regardless of how large your Window is.

Unless you really need it to look that same as it would on paper, for instance.

-Chris

···

--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@...259...

I have overridden the size handler (_onSize) of FigureCanvasWxAgg. In there I essentially added a few lines to set the DPI value with respect to the current canvas size in order to resize elements as suggested by John (using figure.dpi.set). At a first glance everything works as expected. However, if the canvas becomes too small (and apparently with some font types only) I get the following runtime error: "Could not convert glyph to bitmap". Where is the problem?

J�rgen

-------- Original-Nachricht --------

···

Datum: Mon, 14 Jan 2008 18:24:11 -0500
Von: Michael Droettboom <mdroe@...86...>
An: John Hunter <jdh2358@...287...>
CC: DaFudl <juergenwaser@...1843...>, matplotlib-users@lists.sourceforge.net
Betreff: Re: [Matplotlib-users] re sizing behaviour like in Mircrocal Origin

Doh! Why didn't I think of that?

Mike

John Hunter wrote:
> On Jan 14, 2008 3:55 PM, Michael Droettboom <mdroe@...86...> wrote:
>
>> I think what you're asking for would require a pretty major overhaul of
>> matplotlib. The fact that all the text etc. remains the same size is a
>
> matplotlib is designed to scale in the way Jurgen requests with DPI
> (eg fonts, line thicknesses and the like scale with DPI).
>
> In [65]: fig = figure()
>
> In [66]: plot([1,2,3])
> Out[66]: [<matplotlib.lines.Line2D instance at 0xbf965ec>]
>
> In [67]: fig.dpi.set(200)
>
> In [68]: fig.canvas.draw()
>
> with a little work, one could hook into the resize mechanism to
> increase the dpi to create the desired effect w/o a major overhaul.
> By default what happens is the width and height in inches are changed
> with a resize but the dpi is held constant. One could trick
> matplotlib by computing a new width, height in inches, and a new dpi
> so that the resized canvas width in pixels is the requested size based
> on the resize event but the dpi is increased to create the microcal
> effect
>
> JDH

--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA

--
Ist Ihr Browser Vista-kompatibel? Jetzt die neuesten
Browser-Versionen downloaden: http://www.gmx.net/de/go/browser

--
Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
Ideal f�r Modem und ISDN: http://www.gmx.net/de/go/smartsurfer