Skip to content

Commit

Permalink
Fix argument order of save in figure.md (#4088)
Browse files Browse the repository at this point in the history
  • Loading branch information
jariji authored Aug 5, 2024
1 parent c3598fc commit 3977fac
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docs/src/explanations/figure.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ It works exactly the same for vector graphics, just with a different target unit
What are the default values of `px_per_unit` and `pt_per_unit` in each Makie backend, and why are they set that way?

Let us start with `pt_per_unit` because this value is only relevant for one backend, which is CairoMakie.
The default value in CairoMakie is `pt_per_unit = 0.75`. So if you `save(figure, "output.svg")` a `Figure` with `size = (600, 450)`, this comes out as a vector graphic that is 450 x 337.5 pt large.
The default value in CairoMakie is `pt_per_unit = 0.75`. So if you `save("output.svg", figure)` a `Figure` with `size = (600, 450)`, this comes out as a vector graphic that is 450 x 337.5 pt large.

Why 0.75 and not simply 1? This has to do with web standards and device-independent pixels. Websites mix vector graphics and images, so they need some way to relate the sizes of both types to each other. In principle, a pixel in an image doesn't have a real-world width. But you don't want the images on your site to shrink relative to the other content when device pixels are small, or grow when device pixels are large. So web browsers don't directly map image pixels to device pixels. Instead, they use a concept called device-independent pixels. If you place an image with 600 x 450 pixels in a website, this image is interpreted by default to be 600 x 450 device-independent pixels wide. One device-independent pixel is defined to be 0.75 pt wide, that's where the factor 0.75 comes in. So an image with 600 x 450 device-independent pixels is the same apparent size as a vector graphic with size 450 x 337.5 pt. On high-resolution screens, browsers then simply render one device-independent pixel with multiple device pixels (for example 2x2 on an Apple Retina display) so that content stays at readable sizes and doesn't look tiny.

Expand All @@ -200,4 +200,4 @@ We could of course have set up the `Figure` with `size = (3000, 2400)` and then
!!! note
If you keep the intended physical size of an image constant and increase the dpi by increasing `px_per_unit`, the size of text and other content relative to the figure will stay constant.
However, if you instead try to increase the dpi by increasing the Figure size itself, the relative size of text and other content will shrink.
The first option is usually much more convenient, as it keeps the look and layout of the overall figure exactly the same, just with higher resolution.
The first option is usually much more convenient, as it keeps the look and layout of the overall figure exactly the same, just with higher resolution.

0 comments on commit 3977fac

Please sign in to comment.