[Matplotlib-devel] Do we already parse units for sizes (i.e. padding)
Jody Klymak
jklymak at uvic.ca
Fri Aug 25 13:20:15 EDT 2017
Hi all,
I’m trying to work out how to do the padding on my constrained_layout
geometry manager (which is testable by the way if anyone wants to try to
break it for me: https://github.com/matplotlib/matplotlib/pull/9082).
Since I do the constraints in figure-normalized co-ordinates, my pad
variable is figure-normalized, which maybe makes sense for some plots,
but I can easily imagine it will set some people’s OCD off if the
padding is thicker in the horizotnal than the vertical because the
figure is wider than it is tall.
So I could do inches/cm, or pixels, or points. But I guess it’d be
nice to do all four. Do we already have a units parser? I couldn’t
find one. I think it’d be pretty simple: just strip the last two
characters off for unit type and pass the rest as a float.
1.0px (=1.0 px; i.e. strip spaces)
1.0cm
1.0mm
1.0in
1.0pt
I don’t think em and en would make sense in this context because we
wouldn’t know the font size, though maybe there is a sensible figure
default we could use?
Then calls like pad=0.01 and pad=‘5mm’ would both be acceptable.
a) does this exist already?
b) if not, should it?
Thanks, Jody
More information about the Matplotlib-devel
mailing list