7
$\begingroup$

When talking about concepts like ItemSize, ImageSize, FontSize, row/column height within a grid or any other size/scale functions, what units is Mathematica referring to? How are these related to the pixels on the default 100% notebook magnification?

The main reason I'm asking this is because I want to scale a program so that it fits any monitor it is rendered and displayed on. However, I don't really understand how size units are defined in Mathematica.

This must be naturally explained somewhere, but I couldn't find it and so any references are appreciated.

$\endgroup$

1 Answer 1

11
$\begingroup$

There is no universal unit in Mathematica. You will need to check the documentation for each size setting.

Commonly used units include:

  • "Points" usually correspond to pixels on the screen (with Mathematica's default 72 dpi resolution) or printer's points in print. Examples: ImageSize, Offset coordinates, FontSize, etc.

    Sometimes, point sizes can be used in contexts where the default unit is something else through the Offset wrapper.

  • Plot coordinates use the coordinate system of graphics. This is how numbers are interpreted in graphics primitives. Some options, such as PlotRangePadding also use this.

  • Scaled sizes/coordinates are relative to some larger object, which may differ from case to case. Scaled is relative to the plot area when used in graphics. It is relative to the notebook width when used in the ImageSize of a Graphics. ImageScaled is relative to the figure size. And so on.

    In most cases, scaled sizes must be explicitly indicated with the Scaled (or ImageScaled) wrapper and can be used in contexts where the default unit is something different.

  • Units relative to the font size: this is often ems for widths and line height for heights. Examples: Spacings, ItemSize, etc. These are typically used in the context of Grid/Column/Row.

$\endgroup$
6
  • 2
    $\begingroup$ Actually, points are 1/72nd of an inch. The only time that maps 1:1 with pixels is on non-Retina Macs. $\endgroup$
    – ihojnicki
    Jul 8, 2021 at 15:19
  • 2
    $\begingroup$ @ihojnicki The size of a "point" has changed so much and so often that it seems pointless. :) (E.g. a pt in TeX is 1/72.27 inch, which was known for a while as a printer's point, now an American point, as distinguished from the PostScript point, now called the desktop publishing point, which is 1/72 inch and denoted bp in TeX.) $\endgroup$
    – Michael E2
    Jul 8, 2021 at 17:08
  • 1
    $\begingroup$ Much like an Em, which used to be the width of an 'm'. Or a CSS pixel, which is not always a pixel. Units are funny like that. $\endgroup$
    – ihojnicki
    Jul 8, 2021 at 19:22
  • $\begingroup$ @ihojnicki So on Windows and Linux the default is not 1 pixel / 1 point anymore as on macOS? (Or 1 "logical pixel" if you like.) $\endgroup$
    – Szabolcs
    Jul 9, 2021 at 8:42
  • $\begingroup$ @Szabolcs, correct. That was part of the HiDPI update in 12.1. $\endgroup$
    – ihojnicki
    Jul 9, 2021 at 12:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.