My understanding is, the frontend does all its calculations in floating
point and never uses fig.get_width_height() because its always dealing
width width, height in inches and dpi.
'grep' shows that fig.get_width_height() is not used by the frontend,
its only ever used by the backends so it does not really belong in
Figure it belongs it FigureCanvas.
The value of width/height in inches * dpi does not need to be integers,
but what about the ACTUAL width, height values that the backends
The backends will either draw to the display with width, height in
integer pixels, or create an output file png, ps, svg etc, which in most
(all?) cases will have integer width, height.
Does it make sense having an output file 1200.8 x 900.6? What use is the
I ran './simple_plot.py -dAgg' with
to see if I would get the theoretical 1200.8 x 900.6 images.
png and jpg gave 1200 x 900
for svg I used w,h in inches of 8.1, 6.1 (and the default 72 dpi)
the svg file says the width, height is 583.2, 439.2, yet gthumb
shows the image size as 583 x 439.
So there is definitely a float-to-integer conversion/truncation for
width, height taking place.
I suggest moving Figure.get_width_height() to
FigureCanvas.get_width_height() and returning integers. If a backend
really can produce float width, height it can simply override
Send instant messages to your online friends http://au.messenger.yahoo.com
On Wed, 2005-06-15 at 09:22 -0500, John Hunter wrote:
> Figure.get_width_height() returns width, height as floats,
> but isn't width, height of a Figure always integers, and
> wouldn't it make sense to return these as integers?
> This would enable changing the code: width, height =
> figure.get_width_height() width, height = int(width),
> to simply: width, height = figure.get_width_height()
The width and height of a figure are width/height in inches * dpi, and
both dpi and the width/height vars can be floats. So no, these values
don't have to be integers. In the postscript backend, for example, it
returns the width and height of the figure in points. We could add a
convenience kwarg to the method, since in practice it is usually used
by GUI developers who want the dimensions in pixels
w, h = fig.get_width_height(asinteger=True)
If you think this is a good idea, feel free to add it.