Inches?

You have to be careful about the use of global flags which
change the behaviour of a library --- they make it very difficult
to write applications that work on all users machines. Consider
an application where you have two graphs on the same page, and
you want the axes to be aligned. The only way to do this reliably
is to set the margin size. If you write code assuming mm and the
users machine uses inches, the results will not be pretty.

One solution is to attach units to all your values. With a set
of base units that supports multiplication by scalars, this
could be something like:

    figure(figsize=(100*mm,50*mm))

A sensible default such as printer points is needed if no units
are specified.

The reason you need to carry around the units is that you may want
the size to scale with the font. For example, you may want to
provide for 6 digits in the tic labels, so the margin should be
ten times the width of a single digit (allowing for sign and spaces).
Currently margins and legend boxes scale with the size of the plot,
which is not ideal.

Latex uses these units:

  mm Millimetres
  cm Centimetres
  in Inches
  pt Points (1in = 72.27pt)
  pc Picas (1pc = 12pt)
  em The width of the letter M in the current font
  ex The height of the letter x in the current font

- Paul

···

On Sat, Nov 03, 2007 at 05:43:55PM +0100, Olivier Verdier wrote:

This is much worse than I thought. The "inch" unit is used in many places in
matplotlib. In particular in `figure` and `savefig`. Please, please consider
allowing other units. Let me emphasise this once more: in Europe, and, I
believe in most places around the world, one NEVER uses inches. Neither in
engineering nor, i think, in typography. For most people "inch" is basically
an unusual measure of how big screens are. I'm not kidding. Same for dpi,
it's a specific measurement of a resolution but nobody thinks of it as a
number of pixels per inches.
I have nothing against an internal use of inches inside matplotlib but
please consider allowing other units for all kinds of interfaces with the
user!

The best choice in my opinion would be to have a unit preference in the
.matplotlibrc file. This unit could be, say, `inch` or `cm` (or mm). Then
any length would be expressed using this unit of length. That seems simple
enough, doesn't it?