[Matplotlib-devel] Do we already parse units for sizes (i.e. padding)

Benjamin Root ben.v.root at gmail.com
Fri Aug 25 13:53:29 EDT 2017


a) no, it does not exist already
b) at first blush, yes, it would be awesome, and maybe pint might be able
to help us with that.

however... I would caution against getting side-tracked to add such a
feature at the moment. There is a lot of hidden complexities that I think
has not yet been fully appreciated yet. For example, inches and points are
very different from pixels, and would require diving into the transforms
system. We would also open ourselves to a fair amount of confusion from
users. One time, when I was teaching an intro to matplotlib, the tutorial
got derailed by the very first example by a person who was confused that a
figure that was specified to be 7in x 5in wasn't that size on his laptop
screen!

Ben


On Fri, Aug 25, 2017 at 1:20 PM, Jody Klymak <jklymak at uvic.ca> wrote:

> 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
> _______________________________________________
> Matplotlib-devel mailing list
> Matplotlib-devel at python.org
> https://mail.python.org/mailman/listinfo/matplotlib-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-devel/attachments/20170825/5c9cf222/attachment.html>


More information about the Matplotlib-devel mailing list