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