Skip to content

Commit

Permalink
Merge branch 'breaking-0.22' into sd/metamesh
Browse files Browse the repository at this point in the history
  • Loading branch information
ffreyer authored Oct 21, 2024
2 parents d5598de + c164de6 commit 51ce8ff
Show file tree
Hide file tree
Showing 7 changed files with 177 additions and 53 deletions.
1 change: 1 addition & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ NodeJS = "2bd173c7-0d6d-553b-b6af-13a54713934c"
Observables = "510215fc-4207-5dde-b226-833fc4488ee2"
RPRMakie = "22d9f318-5e34-4b44-b769-6e3734a732a6"
RadeonProRender = "27029320-176d-4a42-b57d-56729d2ad457"
Typst_jll = "eb4b1da6-20f6-5c66-9826-fdb8ad410d0e"
WGLMakie = "276b4fcb-3e11-5398-bf8b-a0c2d153d008"
45 changes: 25 additions & 20 deletions docs/makedocs.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Pkg
cd(@__DIR__)
Pkg.activate(".")
pkg"add GeometryBasics#sd/simple-mesh ShaderAbstractions#ff/GeometryBasics_refactor MeshIO#ff/GeometryBasics_refactor"
pkg"add GeometryBasics#master ShaderAbstractions#ff/GeometryBasics_refactor MeshIO#ff/GeometryBasics_refactor"
pkg"dev .. ../MakieCore ../CairoMakie ../GLMakie ../WGLMakie ../RPRMakie"
Pkg.precompile()

Expand Down Expand Up @@ -188,6 +188,7 @@ pages = [
"explanations/transparency.md",
],
"How-Tos" => [
"how-to/match-figure-size-font-sizes-and-dpi.md",
"how-to/draw-boxes-around-subfigures.md",
"how-to/save-figure-with-transparency.md",
],
Expand All @@ -198,25 +199,29 @@ pages = [
]
]

empty!(MakieDocsHelpers.FIGURES)

# filter pages here when working on docs interactively
# pages = nested_filter(pages, r"reference/blocks/(axis|axis3|overview)")

Documenter.makedocs(;
sitename="Makie",
format=DocumenterVitepress.MarkdownVitepress(;
repo = "github.com/MakieOrg/Makie.jl",
devurl = "dev",
devbranch = "master",
deploy_url = "https://docs.makie.org", # for local testing not setting this has broken links with Makie.jl in them
description = "Create impressive data visualizations with Makie, the plotting ecosystem for the Julia language. Build aesthetic plots with beautiful customizable themes, control every last detail of publication quality vector graphics, assemble complex layouts and quickly prototype interactive applications to explore your data live.",
deploy_decision,
),
pages,
expandfirst = unnest(nested_filter(pages, r"reference/(plots|blocks)/(?!overview)")),
warnonly = get(ENV, "CI", "false") != "true",
pagesonly = true,
function make_docs(; pages)
empty!(MakieDocsHelpers.FIGURES)

Documenter.makedocs(;
sitename="Makie",
format=DocumenterVitepress.MarkdownVitepress(;
repo = "github.com/MakieOrg/Makie.jl",
devurl = "dev",
devbranch = "master",
deploy_url = "https://docs.makie.org", # for local testing not setting this has broken links with Makie.jl in them
description = "Create impressive data visualizations with Makie, the plotting ecosystem for the Julia language. Build aesthetic plots with beautiful customizable themes, control every last detail of publication quality vector graphics, assemble complex layouts and quickly prototype interactive applications to explore your data live.",
deploy_decision,
),
pages,
expandfirst = unnest(nested_filter(pages, r"reference/(plots|blocks)/(?!overview)")),
warnonly = get(ENV, "CI", "false") != "true",
pagesonly = true,
)
end

make_docs(;
# filter pages here when working on docs interactively
pages # = nested_filter(pages, r"explanations/figure|match-figure"),
)

##
Expand Down
110 changes: 80 additions & 30 deletions docs/src/explanations/figure.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/src/explanations/scenes.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ A Scene's subscenes (also called children) can be accessed through `scene.childr

Any `Scene` with an axis also has a `camera` associated with it; this can be accessed through `camera(scene)`, and its controls through `cameracontrols(scene)`. More documentation about these is in the [Cameras](@ref) section.

`Scene`s have a configurable size. You can set the size in device-independent pixels by doing `Scene(size = (500, 500))`. (More about sizes, resolutions and units in [Figure size and units](@ref))
`Scene`s have a configurable size. You can set the size in device-independent pixels by doing `Scene(size = (500, 500))`. (More about sizes, resolutions and units in [Figure size and resolution](@ref) or [How to match Figure size, font sizes and dpi](@ref))

Any keyword argument given to the `Scene` will be propagated to its plots; therefore, you can set the palette or the colormap in the Scene itself.

Expand Down
68 changes: 68 additions & 0 deletions docs/src/how-to/match-figure-size-font-sizes-and-dpi.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# How to match Figure size, font sizes and dpi

We want to create three plots for inclusion in a document. These are the requirements:

- Figure 1: png @ 4x3 inches and 100 dpi
- Figure 2: png @ 9x7 cm and 300 dpi
- Figure 3: svg @ 4x3 inches

The fontsize of all three should match the document's 12pt setting.

We assume the convention that Makie's unitless figure size is actually equivalent to CSS pixels.
For a deeper explanation why, check the section [Figure size and resolution](@ref).

We're using Typst here but the technique applies similarly for all authoring tools that allow you to set the dimensions of included images.

```@example
using CairoMakie
CairoMakie.activate!() # hide
using Typst_jll
# these are relative to 1 CSS px
inch = 96
pt = 4/3
cm = inch / 2.54
f1 = Figure(size = (4inch, 3inch), fontsize = 12pt)
f2 = Figure(size = (9cm, 7cm), fontsize = 12pt)
f3 = Figure(size = (4inch, 3inch), fontsize = 12pt)
titles = [
"Figure 1: png @ 4x3 inches and 100 dpi",
"Figure 2: png @ 9x7 cm and 300 dpi",
"Figure 3: svg @ 4x3 inches",
]
data = cumsum(randn(100))
for (f, title) in zip([f1, f2, f3], titles)
ax = Axis(f[1, 1]; title, xlabel = "time (s)", ylabel = "value (€)")
lines!(ax, data)
end
save("figure1.png", f1, px_per_unit = 100/inch)
save("figure2.png", f2, px_per_unit = 300/inch)
save("figure3.svg", f3)
typst_code = """
#set page(fill: rgb("#f5f2eb"))
#set text(font: "TeX Gyre Heros Makie", size: 12pt, fill: luma(50%))
This is some text at 12pt which the figures below should match.
#image("figure1.png", width: 4in, height: 3in)
#image("figure2.png", width: 9cm, height: 7cm)
#image("figure3.svg") // vector graphics have physical dimensions
"""
open(io -> println(io, typst_code), "document.typ", "w")
cp(Makie.assetpath("fonts", "TeXGyreHerosMakie-Regular.otf"), "./texgyre.otf")
run(`$(Typst_jll.typst()) compile --font-path . document.typ output.svg`)
nothing # hide
```

![](output.svg)

2 changes: 1 addition & 1 deletion metrics/ttfp/run-benchmark.jl
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ pkgs = NamedTuple[(; path="./MakieCore"), (; path="."), (; path="./$Package")]
# cd("dev/Makie")
Pkg.develop(pkgs)
Pkg.add([(; name="BenchmarkTools")])
pkg"add GeometryBasics#sd/simple-mesh MeshIO#ff/GeometryBasics_refactor ShaderAbstractions#ff/GeometryBasics_refactor"
pkg"add GeometryBasics#master MeshIO#ff/GeometryBasics_refactor ShaderAbstractions#ff/GeometryBasics_refactor"


@time Pkg.precompile()
Expand Down
2 changes: 1 addition & 1 deletion relocatability.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ cd(tmpdir)
Pkg.generate("MakieApp")
Pkg.activate("MakieApp")

pkg"add GeometryBasics#sd/simple-mesh MeshIO#ff/GeometryBasics_refactor ShaderAbstractions#ff/GeometryBasics_refactor"
pkg"add GeometryBasics#master MeshIO#ff/GeometryBasics_refactor ShaderAbstractions#ff/GeometryBasics_refactor"

makie_dir = @__DIR__
commit = cd(makie_dir) do
Expand Down

0 comments on commit 51ce8ff

Please sign in to comment.