# Makie: PDF paper size (or MadiaBox)?

**URL:** <https://discourse.julialang.org/t/makie-pdf-paper-size-or-madiabox/106900>\
**Category:** Visualization\
**Tags:** question, makie\
**Created:** [November 29, 2023, 1:37pm UTC](https://discourse.julialang.org/t/makie-pdf-paper-size-or-madiabox/106900 "2023-11-29T13:37:35Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![ryofurue](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ryofurue/32/24531_2.png) [@ryofurue](https://discourse.julialang.org/u/ryofurue)\
**Post date:** [November 29, 2023, 1:37pm UTC](https://discourse.julialang.org/t/makie-pdf-paper-size-or-madiabox/106900/1 "2023-11-29T13:37:35Z")

</div>

How do you specify the paper size of the PDF image? Alternatively, how do you control the physical size of the axes? I must be fundamentally misunderstanding how the sizing of the plot works.

In the example at the end of this massage, I specify `size` both for `Figure()` and `save()` to be 100 × 80 mm but the paper size (MediaBox) of the resultant PDF is 211.7 × 158.7 mm, which is 600 × 450 pt. (You can view this information in the “Properties” menu of Adobe Reader, or by clicking on the “i” button on Preview. The PDF file also includes the statement `/MediaBox [0 0 600 450]`.)

**[Edit: It turns out that the version of `Makie` I was using didn’t support `size`, which was the primary reason why the paper size didn’t change. See below for details.]**

As a result, the text is too small and lines are too thin.

[I’m not asking how to change font size and line width. Rather, changing the physical size of the plots is much easier to make them suitable to be included in a PDF document. Because the main text would be 10 to 12pt, the letterings in the figure should be 9pt or 10pt. The default line width would be probably fine if the figure is 100 × 80 mm . . .]

```julia
using CairoMakie

mm2pt = let mm2in = 1/25.4, in2pt = 72
  mm2in * in2pt
end
@show mm2pt

"papersize"
(wid_mm,hei_mm) = (100.0,80.0) # millimeter
(wid_pt, hei_pt) = (wid_mm, hei_mm) .* mm2pt
figsize = (wid_pt, hei_pt)
@show figsize

fig = Figure(size = figsize)
ax = Axis(fig[1,1])
save("tmp.pdf", fig, size=figsize)

```

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [November 29, 2023, 1:47pm UTC](https://discourse.julialang.org/t/makie-pdf-paper-size-or-madiabox/106900/2 "2023-11-29T13:47:29Z")

</div>

Have you already had a look at this page? [Figures · Makie](https://docs.makie.org/stable/explanations/figure/#figure_size_and_units)

Look for `pt_per_unit` there and why it’s 0.75 by default

---

<div class="post-metadata">

**Author:** ![ryofurue](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ryofurue/32/24531_2.png) [@ryofurue](https://discourse.julialang.org/u/ryofurue)\
**Post date:** [November 29, 2023, 1:54pm UTC](https://discourse.julialang.org/t/makie-pdf-paper-size-or-madiabox/106900/3 "2023-11-29T13:54:48Z")

</div>

> [@jules](#):
>
> Have you already had a look at this page? [Figures · Makie](https://docs.makie.org/stable/explanations/figure/#figure_size_and_units)

No! How do you find it? What keyword do you use to arrive at the page?

I feel really stupid with Makie. Somehow I’m unable to locate relevant documents!!!

I of course went to [https://docs.makie.org/](https://docs.makie.org/) and looked at various pages. I of course searched google. I of course searched this forum. I think I’m normally very good at finding relevant technical information . . .

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [November 29, 2023, 1:57pm UTC](https://discourse.julialang.org/t/makie-pdf-paper-size-or-madiabox/106900/4 "2023-11-29T13:57:37Z")

</div>

The page is relatively new so might not be indexed yet. I didn’t find it, I wrote it 😄

Static page search is relatively dumb so if you don’t look for the right keywords it’s easier to miss stuff than with google

---

<div class="post-metadata">

**Author:** ![ericphanson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ericphanson/32/215186_2.png) [@ericphanson](https://discourse.julialang.org/u/ericphanson)\
**Post date:** [November 29, 2023, 2:29pm UTC](https://discourse.julialang.org/t/makie-pdf-paper-size-or-madiabox/106900/5 "2023-11-29T14:29:00Z")

</div>

Btw one tip for Makie, I often use GitHub’s code search to search the repository. It often finds the docs faster than through website. It’ll also find issues and such which can be helpful.

---

<div class="post-metadata">

**Author:** ![ryofurue](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ryofurue/32/24531_2.png) [@ryofurue](https://discourse.julialang.org/u/ryofurue)\
**Post date:** [November 29, 2023, 2:39pm UTC](https://discourse.julialang.org/t/makie-pdf-paper-size-or-madiabox/106900/6 "2023-11-29T14:39:33Z")

</div>

Sorry I still fail to understand.

I carefully read and re-read the explanation of `pt_per_unit` and I thought I understood this part:

> A `Figure` with `size = (600, 450)` will be 600 x 450 points in size when exported with `pt_per_unit = 1` , 300 x 225 with `pt_per_unit = 0.5` and 1200 x 900 with `pt_per_unit = 2` .

So, a figure with `size = (300,255)` with `pt_per_unit = 1` will produce a page 300 × 450 pt.

But the following code still produces a page of 800 × 600 pt . . .

```julia
using CairoMakie
"papersize"
figsize = (300,255)
fig = Figure(fontsize=9, size=figsize, pt_per_unit = 1)
ax = Axis(fig[1,1])
save("tmp.pdf", fig, size=figsize, pt_per_unit = 1)

```

By the way, I don’t know where to put `pt_per_unit` and `size`.

---

<div class="post-metadata">

**Author:** ![ryofurue](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ryofurue/32/24531_2.png) [@ryofurue](https://discourse.julialang.org/u/ryofurue)\
**Post date:** [November 29, 2023, 2:42pm UTC](https://discourse.julialang.org/t/makie-pdf-paper-size-or-madiabox/106900/7 "2023-11-29T14:42:17Z")

</div>

> I often use GitHub’s code search to search the repository.

I tried that feature sometime ago, but the search seemed to search for filenames. Your words seem to indicate that you can search the contents of the files.

---

<div class="post-metadata">

**Author:** ![ryofurue](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ryofurue/32/24531_2.png) [@ryofurue](https://discourse.julialang.org/u/ryofurue)\
**Post date:** [November 29, 2023, 2:53pm UTC](https://discourse.julialang.org/t/makie-pdf-paper-size-or-madiabox/106900/8 "2023-11-29T14:53:46Z")

</div>

[I’ve deleted my original comment. Sorry!]

---

<div class="post-metadata">

**Author:** ![ericphanson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ericphanson/32/215186_2.png) [@ericphanson](https://discourse.julialang.org/u/ericphanson)\
**Post date:** [November 29, 2023, 3:01pm UTC](https://discourse.julialang.org/t/makie-pdf-paper-size-or-madiabox/106900/9 "2023-11-29T15:01:13Z")

</div>

If I search for [figure size](https://github.com/search?q=repo%3AMakieOrg%2FMakie.jl+figure+size&type=code), the first result seems to be the docs Julius linked:

 ![Screenshot 2023-11-29 at 16.00.53](https://global.discourse-cdn.com/julialang/original/3X/d/e/de23dbc6e180731228b311167e74767757ea7127.png)

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [November 29, 2023, 3:10pm UTC](https://discourse.julialang.org/t/makie-pdf-paper-size-or-madiabox/106900/10 "2023-11-29T15:10:50Z")

</div>

Are you on 0.20? You getting a 800x600 figure indicates that the new size keyword is ignored and the default is still the old one, so you’re probably on 0.19

---

<div class="post-metadata">

**Author:** ![ryofurue](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ryofurue/32/24531_2.png) [@ryofurue](https://discourse.julialang.org/u/ryofurue)\
**Post date:** [November 29, 2023, 4:22pm UTC](https://discourse.julialang.org/t/makie-pdf-paper-size-or-madiabox/106900/11 "2023-11-29T16:22:35Z")

</div>

OMG! It seems my Julia installation was corrupted, perhaps similarly to

> <https://stackoverflow.com/questions/44220363/in-julia-how-do-you-check-list-update-your-packages>

I just didn’t realize that `CairoMakie` remained “updatable” even after I updated all packages.

Since the method suggested in the Stackoverflow thread I quote above didn’t work for me, I just deleted everything under `~/.julia` and stated over.

This time I got the latest version of `CarioMakie` as shown below and I was of course able to scale the figure as described in your document.

Phew! Thanks!

```julia
(@v1.9) pkg> status
Status `~/.julia/environments/v1.9/Project.toml`
  [13f3f980] CairoMakie v0.11.1

```

---

<div class="post-metadata">

**Author:** ![ryofurue](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ryofurue/32/24531_2.png) [@ryofurue](https://discourse.julialang.org/u/ryofurue)\
**Post date:** [November 30, 2023, 2:03am UTC](https://discourse.julialang.org/t/makie-pdf-paper-size-or-madiabox/106900/12 "2023-11-30T02:03:49Z")

</div>

@jules Are you the second author of this paper, [https://joss.theoj.org/papers/10.21105/joss.03349](https://joss.theoj.org/papers/10.21105/joss.03349) ? In the manuscript I’m writing now, I plan to mention you in the “acknowledgements” section for answering so many (often stupid) questions from me, as well as citing the paper. (I tried to find a way to private-message you but didn’t find it.)

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [November 30, 2023, 6:31am UTC](https://discourse.julialang.org/t/makie-pdf-paper-size-or-madiabox/106900/13 "2023-11-30T06:31:27Z")

</div>

Yes that would be me, now you know _why_ I’m answering questions all the time 😉

---

<div class="post-metadata">

**Author:** ![ryofurue](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ryofurue/32/24531_2.png) [@ryofurue](https://discourse.julialang.org/u/ryofurue)\
**Post date:** [November 30, 2023, 7:11am UTC](https://discourse.julialang.org/t/makie-pdf-paper-size-or-madiabox/106900/14 "2023-11-30T07:11:40Z")

</div>

By the way, my assessment

> [@ryofurue](#):
>
> It seems my Julia installation was corrupted

was totally wrong. I’m now on a different Mac machine and had exactly the same problem.

I then learned why a package which “may be upgradable” (as reported by `Pkg.status`) is not upgraded unless you force it by specifying the desired version number.

In my particular case, `CairoMakie` and `NCDatasets` weren’t upgraded. When I forced them to be their latest versions, a lot of other packages were downgraded. But, after removing `Rasters`, all potentially “upgradable” packages were upgraded. So, it seems (although I’m not 100% sure) that that was because `Rasters` depends on older versions of some packages on which `Makie` depends.
