diff --git a/docs/src/backends_and_output.md b/docs/src/backends_and_output.md index 5f83578ed..30a270386 100644 --- a/docs/src/backends_and_output.md +++ b/docs/src/backends_and_output.md @@ -67,14 +67,19 @@ CairoMakie.activate!(type = "svg") When you save a CairoMakie figure, you can change the mapping from figure resolution to pixels (when saving to png) or points (when saving to svg or pdf). This way you can easily scale the resulting image up or down without having to change any plot element sizes. -Just specify `pt_per_unit` when saving vector formats and `px_per_unit` when saving pngs. Both default to 1. +Just specify `pt_per_unit` when saving vector formats and `px_per_unit` when saving pngs. +`px_per_unit` defaults to 1 and `pt_per_unit` defaults to 0.75. +When embedding svgs in websites, `1px` is equivalent to `0.75pt`. +This means that by default, saving a png or an svg results in an embedded image of the same apparent size. +If you require an exact size in `pt`, consider setting `pt_per_unit = 1`. + Here's an example: ```julia fig = Figure(resolution = (800, 600)) -save("normal.pdf", fig) # size = 800 x 600 pt +save("normal.pdf", fig) # size = 600 x 450 pt save("larger.pdf", fig, pt_per_unit = 2) # size = 1600 x 1200 pt save("smaller.pdf", fig, pt_per_unit = 0.5) # size = 400 x 300 pt diff --git a/docs/src/basic-tutorial.md b/docs/src/basic-tutorial.md index d2f8cf78c..42f05c396 100644 --- a/docs/src/basic-tutorial.md +++ b/docs/src/basic-tutorial.md @@ -292,7 +292,7 @@ This is useful as we can then continue with the figure `f` and the heatmap `hm` using CairoMakie f, ax, hm = heatmap(randn(20, 20)) -Colorbar(f[1, 2], hm, width = 20) +Colorbar(f[1, 2], hm) f ``` @@ -305,7 +305,7 @@ using CairoMakie f = Figure() ax = Axis(f[1, 1]) hm = heatmap!(ax, randn(20, 20)) -Colorbar(f[1, 2], hm, width = 20) +Colorbar(f[1, 2], hm) f ``` @@ -320,7 +320,7 @@ You can pass your axis attributes under the keyword `axis` and your figure attri using CairoMakie heatmap(randn(20, 20), - figure = (resolution = (800, 600), backgroundcolor = :pink), + figure = (backgroundcolor = :pink,), axis = (aspect = 1, xlabel = "x axis", ylabel = "y axis") ) ``` diff --git a/docs/src/figure.md b/docs/src/figure.md index ac194c0b4..2fe7123d9 100644 --- a/docs/src/figure.md +++ b/docs/src/figure.md @@ -59,7 +59,7 @@ This object can be used to plot a new axis into a certain layout position in the using CairoMakie CairoMakie.activate!() # hide -f = Figure(resolution = (800, 600)) +f = Figure() pos = f[1, 1] scatter(pos, rand(100, 2)) @@ -81,7 +81,7 @@ Often, a desired plot layout can only be achieved with nesting, and repeatedly i using CairoMakie CairoMakie.activate!() # hide -f = Figure(resolution = (800, 600)) +f = Figure() f[1, 1] = Axis(f, title = "I'm not nested") f[1, 2][1, 1] = Axis(f, title = "I'm nested") @@ -100,6 +100,25 @@ All nested grid layouts that don't exist yet, but are needed for a nested plotti value for further manipulation. You can instead retrieve them after the fact with the `content` function, for example, as explained in the following section. +## Figure padding + +You can change the amount of whitespace around the figure content with the keyword `figure_padding`. +This takes either a number for all four sides, or a tuple of four numbers for left, right, bottom, top. +You can also theme this setting with `set_theme!(figure_padding = 30)`, for example. + +```@example +using CairoMakie +CairoMakie.activate!() # hide + +f = Figure(figure_padding = 1, backgroundcolor = :gray80) + +Axis(f[1, 1]) +scatter!(1:10) + +f +``` + + ## Retrieving Objects From A Figure Sometimes users are surprised that indexing into a figure does not retrieve the object placed at that position. diff --git a/docs/src/makielayout/axis.md b/docs/src/makielayout/axis.md index 2014ad76d..1ba1ab330 100755 --- a/docs/src/makielayout/axis.md +++ b/docs/src/makielayout/axis.md @@ -13,7 +13,7 @@ Here's how you create one ```@example laxis using CairoMakie -f = Figure(resolution = (1200, 900)) +f = Figure() ax = Axis(f[1, 1], xlabel = "x label", ylabel = "y label", title = "Title") @@ -46,7 +46,7 @@ using CairoMakie CairoMakie.activate!() # hide AbstractPlotting.inline!(true) # hide -f = Figure(resolution = (1200, 500)) +f = Figure() axs = [Axis(f[1, i]) for i in 1:3] @@ -78,7 +78,7 @@ using CairoMakie CairoMakie.activate!() # hide AbstractPlotting.inline!(true) # hide -f = Figure(resolution = (1200, 900)) +f = Figure() axes = [Axis(f[i, j]) for j in 1:3, i in 1:2] @@ -108,7 +108,7 @@ using CairoMakie CairoMakie.activate!() # hide AbstractPlotting.inline!(true) # hide -f = Figure(resolution = (800, 400)) +f = Figure() lines(f[1, 1], 0..10, sin) lines(f[1, 2], 0..10, sin, axis = (limits = (0, 10, -1, 1),)) @@ -148,7 +148,7 @@ The default tick type is `LinearTicks(n)`, where `n` is the target number of tic ```@example using CairoMakie -fig = Figure(resolution = (1200, 900)) +fig = Figure() for (i, n) in enumerate([2, 5, 9]) lines(fig[i, 1], 0..20, sin, axis = (xticks = LinearTicks(n),)) end @@ -218,7 +218,7 @@ theme = Attributes( ) fig = with_theme(theme) do - fig = Figure(resolution = (800, 800)) + fig = Figure() axs = [Axis(fig[fldmod1(n, 2)...], title = "IntervalsBetween($(n+1))", xminorticks = IntervalsBetween(n+1), @@ -240,7 +240,7 @@ To hide spines, you can use `hidespines!`. ```@example using CairoMakie -f = Figure(resolution = (1200, 900)) +f = Figure() ax1 = Axis(f[1, 1], title = "Axis 1") ax2 = Axis(f[1, 2], title = "Axis 2") @@ -260,7 +260,7 @@ It's common, e.g., to hide everything but the grid lines in facet plots. ```@example using CairoMakie -f = Figure(resolution = (1200, 700)) +f = Figure() ax1 = Axis(f[1, 1], title = "Axis 1") ax2 = Axis(f[1, 2], title = "Axis 2") @@ -284,7 +284,7 @@ using CairoMakie data = LinRange(0.01, 0.99, 200) -f = Figure(resolution = (1000, 1000), fontsize = 14) +f = Figure(resolution = (800, 800)) for (i, scale) in enumerate([identity, log10, log2, log, sqrt, AbstractPlotting.logit]) @@ -336,12 +336,12 @@ using FileIO using Random # hide Random.seed!(1) # hide -f = Figure(resolution = (1200, 900)) +f = Figure() axes = [Axis(f[i, j]) for i in 1:2, j in 1:3] tightlimits!.(axes) -img = rotr90(load("../assets/cow.png")) +img = rotr90(load(assetpath("cow.png"))) for ax in axes image!(ax, img) @@ -361,8 +361,8 @@ axes[2, 1].aspect = AxisAspect(1) axes[2, 2].title = "AxisAspect(2)" axes[2, 2].aspect = AxisAspect(2) -axes[2, 3].title = "AxisAspect(0.5)" -axes[2, 3].aspect = AxisAspect(0.5) +axes[2, 3].title = "AxisAspect(2/3)" +axes[2, 3].aspect = AxisAspect(2/3) f ``` @@ -450,7 +450,7 @@ separately. ```@example using CairoMakie -f = Figure(resolution = (1200, 900)) +f = Figure() ax1 = Axis(f[1, 1]) ax2 = Axis(f[1, 2]) @@ -485,7 +485,7 @@ You can change this with the attributes `xaxisposition = :top` and `yaxispositio ```@example using CairoMakie -f = Figure(resolution = (800, 800)) +f = Figure() for i in 1:2, j in 1:2 Axis( @@ -508,7 +508,7 @@ Here's an example how to do this with a second y axis on the right. ```@example using CairoMakie -f = Figure(resolution = (800, 600)) +f = Figure() ax1 = Axis(f[1, 1], yticklabelcolor = :blue) ax2 = Axis(f[1, 1], yticklabelcolor = :red, yaxisposition = :right) diff --git a/docs/src/makielayout/box.md b/docs/src/makielayout/box.md index f00f8930d..49dd81e3b 100644 --- a/docs/src/makielayout/box.md +++ b/docs/src/makielayout/box.md @@ -12,7 +12,7 @@ facet plots or when a rectangular placeholder is needed. using CairoMakie using ColorSchemes -fig = Figure(resolution = (1200, 900)) +fig = Figure() rects = fig[1:4, 1:6] = [ Box(fig, color = c) diff --git a/docs/src/makielayout/button.md b/docs/src/makielayout/button.md index 505100c66..4efe69b79 100644 --- a/docs/src/makielayout/button.md +++ b/docs/src/makielayout/button.md @@ -8,7 +8,7 @@ CairoMakie.activate!() ```@example using GLMakie -fig = Figure(resolution = (1200, 900)) +fig = Figure() ax = Axis(fig[1, 1]) fig[2, 1] = buttongrid = GridLayout(tellwidth = false) diff --git a/docs/src/makielayout/colorbar.md b/docs/src/makielayout/colorbar.md index da102a3f3..6252021d3 100644 --- a/docs/src/makielayout/colorbar.md +++ b/docs/src/makielayout/colorbar.md @@ -14,24 +14,24 @@ Here's how you can create Colorbars manually. ```@example using CairoMakie -fig = Figure(resolution = (1200, 900)) +fig = Figure() Axis(fig[1, 1]) # vertical colorbars -Colorbar(fig[1, 2], width = 25, limits = (0, 10), colormap = :viridis, +Colorbar(fig[1, 2], limits = (0, 10), colormap = :viridis, flipaxis = false) -Colorbar(fig[1, 3], width = 25, limits = (0, 5), -colormap = cgrad(:Spectral, 5, categorical = true)) -Colorbar(fig[1, 4], width = 25, limits = (-1, 1), colormap = :heat, +Colorbar(fig[1, 3], limits = (0, 5), + colormap = cgrad(:Spectral, 5, categorical = true), size = 25) +Colorbar(fig[1, 4], limits = (-1, 1), colormap = :heat, highclip = :cyan, lowclip = :red, label = "Temperature") # horizontal colorbars -Colorbar(fig[2, 1], height = 25, limits = (0, 10), colormap = :viridis, +Colorbar(fig[2, 1], limits = (0, 10), colormap = :viridis, vertical = false) -Colorbar(fig[3, 1], height = 25, limits = (0, 5), +Colorbar(fig[3, 1], limits = (0, 5), size = 25, colormap = cgrad(:Spectral, 5, categorical = true), vertical = false) -Colorbar(fig[4, 1], height = 25, limits = (-1, 1), colormap = :heat, +Colorbar(fig[4, 1], limits = (-1, 1), colormap = :heat, label = "Temperature", vertical = false, flipaxis = false, highclip = :cyan, lowclip = :red) @@ -47,22 +47,22 @@ xs = LinRange(0, 20, 50) ys = LinRange(0, 15, 50) zs = [cos(x) * sin(y) for x in xs, y in ys] -fig = Figure(resolution = (1200, 900)) +fig = Figure() ax, hm = heatmap(fig[1, 1][1, 1], xs, ys, zs) -Colorbar(fig[1, 1][1, 2], hm, width = 20) +Colorbar(fig[1, 1][1, 2], hm) ax, hm = heatmap(fig[1, 2][1, 1], xs, ys, zs, colormap = :grays, colorrange = (-0.75, 0.75), highclip = :red, lowclip = :blue) -Colorbar(fig[1, 2][1, 2], hm, width = 20) +Colorbar(fig[1, 2][1, 2], hm) ax, hm = contourf(fig[2, 1][1, 1], xs, ys, zs, levels = -1:0.25:1, colormap = :heat) -Colorbar(fig[2, 1][1, 2], hm, width = 20, ticks = -1:0.25:1) +Colorbar(fig[2, 1][1, 2], hm, ticks = -1:0.25:1) ax, hm = contourf(fig[2, 2][1, 1], xs, ys, zs, colormap = :Spectral, levels = [-1, -0.5, -0.25, 0, 0.25, 0.5, 1]) -Colorbar(fig[2, 2][1, 2], hm, width = 20, ticks = -1:0.25:1) +Colorbar(fig[2, 2][1, 2], hm, ticks = -1:0.25:1) fig ``` diff --git a/docs/src/makielayout/gridlayout.md b/docs/src/makielayout/gridlayout.md index 3970ccfea..c6f6147f8 100755 --- a/docs/src/makielayout/gridlayout.md +++ b/docs/src/makielayout/gridlayout.md @@ -41,7 +41,7 @@ scene, layout = layoutscene(resolution = (1200, 900)) layout[1, 1] = Axis(scene, title = "My column has size Relative(2/3)") layout[1, 2] = Axis(scene, title = "My column has size Auto()") -layout[1, 3] = Colorbar(scene, width = 30) +layout[1, 3] = Colorbar(scene) colsize!(layout, 1, Relative(2/3)) @@ -267,7 +267,7 @@ columns respectively. ```@example spacing using CairoMakie -fig = Figure(resolution = (1200, 900)) +fig = Figure() axs = [Axis(fig[i, j]) for i in 1:3, j in 1:3] axs[1, 1].title = "Group A" diff --git a/docs/src/makielayout/intervalslider.md b/docs/src/makielayout/intervalslider.md index 47739a63e..3b586094a 100644 --- a/docs/src/makielayout/intervalslider.md +++ b/docs/src/makielayout/intervalslider.md @@ -25,7 +25,7 @@ using CairoMakie # hide AbstractPlotting.inline!(true) # hide CairoMakie.activate!() # hide -f = Figure(resolution = (800, 800)) +f = Figure() Axis(f[1, 1], limits = (0, 1, 0, 1)) rs_h = IntervalSlider(f[2, 1], range = LinRange(0, 1, 1000), diff --git a/docs/src/makielayout/label.md b/docs/src/makielayout/label.md index cd5f5d163..a233bd069 100644 --- a/docs/src/makielayout/label.md +++ b/docs/src/makielayout/label.md @@ -11,7 +11,7 @@ so rows and columns in a GridLayout can shrink to the appropriate width or heigh ```@example using CairoMakie -fig = Figure(resolution = (1200, 900)) +fig = Figure() fig[1:2, 1:3] = [Axis(fig) for _ in 1:6] diff --git a/docs/src/makielayout/layoutables.md b/docs/src/makielayout/layoutables.md index 2253c8ca4..2fb2fb3ef 100755 --- a/docs/src/makielayout/layoutables.md +++ b/docs/src/makielayout/layoutables.md @@ -24,7 +24,7 @@ using CairoMakie CairoMakie.activate!() # hide AbstractPlotting.inline!(true) # hide -f = Figure(resolution = (800, 600)) +f = Figure() ax = Axis(f[1, 1]) f ``` @@ -40,7 +40,7 @@ using CairoMakie CairoMakie.activate!() # hide AbstractPlotting.inline!(true) # hide -scene, layout = layoutscene(resolution = (800, 600)) +scene, layout = layoutscene() ax = layout[1, 1] = Axis(scene) scene ``` @@ -59,7 +59,7 @@ using CairoMakie CairoMakie.activate!() # hide AbstractPlotting.inline!(true) # hide -f = Figure(resolution = (800, 600)) +f = Figure() Axis(f, bbox = BBox(100, 300, 100, 500), title = "Axis 1") Axis(f, bbox = BBox(400, 700, 200, 400), title = "Axis 2") f diff --git a/docs/src/makielayout/legend.md b/docs/src/makielayout/legend.md index 561ed8b05..271d58180 100755 --- a/docs/src/makielayout/legend.md +++ b/docs/src/makielayout/legend.md @@ -15,19 +15,18 @@ Or they can be vectors of such objects that will be layered together as one. ```@example using CairoMakie -scene, layout = layoutscene(resolution = (1400, 900)) +f = Figure() -ax = layout[1, 1] = Axis(scene) +Axis(f[1, 1]) xs = 0:0.5:10 ys = sin.(xs) -lin = lines!(ax, xs, ys, color = :blue) -sca = scatter!(ax, xs, ys, color = :red, markersize = 15) +lin = lines!(xs, ys, color = :blue) +sca = scatter!(xs, ys, color = :red, markersize = 15) -leg = Legend(scene, [lin, sca, [lin, sca]], ["a line", "some dots", "both together"]) -layout[1, 2] = leg +Legend(f[1, 2], [lin, sca, [lin, sca]], ["a line", "some dots", "both together"]) -scene +f ``` ## Creating A Legend From An Axis @@ -60,17 +59,16 @@ when in vertical mode, and rows when in horizontal mode. ```@example using CairoMakie -scene, layout = layoutscene(resolution = (1400, 900)) +f = Figure() -ax = layout[1, 1] = Axis(scene) +Axis(f[1, 1]) xs = 0:0.1:10 -lins = [lines!(ax, xs, sin.(xs .+ 3v), color = RGBf0(v, 0, 1-v)) for v in 0:0.1:1] +lins = [lines!(xs, sin.(xs .+ 3v), color = RGBf0(v, 0, 1-v)) for v in 0:0.1:1] -leg = Legend(scene, lins, string.(1:length(lins)), nbanks = 3) -layout[1, 2] = leg +Legend(f[1, 2], lins, string.(1:length(lins)), nbanks = 3) -scene +f ``` @@ -85,7 +83,7 @@ The position can be set via a shortcut symbol, first halign (l, r, c) then valig ```@example using CairoMakie -f = Figure(resolution = (800, 600)) +f = Figure() ax = Axis(f[1, 1]) @@ -117,29 +115,26 @@ using CairoMakie haligns = [:left, :right, :center] valigns = [:top, :bottom, :center] -scene, layout = layoutscene(resolution = (1400, 900)) +f = Figure() -ax = layout[1, 1] = Axis(scene) +Axis(f[1, 1]) xs = 0:0.1:10 -lins = [lines!(ax, xs, sin.(xs .* i), color = color) +lins = [lines!(xs, sin.(xs .* i), color = color) for (i, color) in zip(1:3, [:red, :blue, :green])] -legends = [Legend( - scene, lins, ["Line $i" for i in 1:3], +for (j, ha, va) in zip(1:3, haligns, valigns) + Legend( + f[1, 1], lins, ["Line $i" for i in 1:3], "$ha & $va", tellheight = false, tellwidth = false, margin = (10, 10, 10, 10), halign = ha, valign = va, orientation = :horizontal - ) for (j, ha, va) in zip(1:3, haligns, valigns)] - - -for leg in legends - layout[1, 1] = leg + ) end -scene +f ``` @@ -162,9 +157,9 @@ MakieLayout.attributenames(LegendEntry) ```@example using CairoMakie -scene, layout = layoutscene(resolution = (1400, 900)) +f = Figure() -ax = layout[1, 1] = Axis(scene) +Axis(f[1, 1]) elem_1 = [LineElement(color = :red, linestyle = nothing), @@ -184,12 +179,12 @@ elem_5 = PolyElement(color = :green, strokecolor = :black, polypoints = Point2f0[(0, 0), (1, 0), (0, 1)]) -leg = layout[1, 2] = Legend(scene, +Legend(f[1, 2], [elem_1, elem_2, elem_3, elem_4, elem_5], ["Line & Marker", "Poly & Line", "Line", "Marker", "Poly"], - patchsize = (35, 35)) + patchsize = (35, 35), rowgap = 10) -scene +f ``` @@ -206,23 +201,21 @@ if you place the legend below or above the axis. ```@example using CairoMakie -scene, layout = layoutscene(resolution = (1400, 900)) +f = Figure() -ax = layout[1, 1] = Axis(scene) +Axis(f[1, 1]) xs = 0:0.5:10 ys = sin.(xs) -lin = lines!(ax, xs, ys, color = :blue) -sca = scatter!(ax, xs, ys, color = :red, markersize = 15) +lin = lines!(xs, ys, color = :blue) +sca = scatter!(xs, ys, color = :red, markersize = 15) -leg = Legend(scene, [lin, sca, lin], ["a line", "some dots", "line again"]) -layout[1, 2] = leg +Legend(f[1, 2], [lin, sca, lin], ["a line", "some dots", "line again"]) -leg_horizontal = Legend(scene, [lin, sca, lin], ["a line", "some dots", "line again"], +Legend(f[2, 1], [lin, sca, lin], ["a line", "some dots", "line again"], orientation = :horizontal, tellwidth = false, tellheight = true) -layout[2, 1] = leg_horizontal -scene +f ``` @@ -238,15 +231,15 @@ You can shift the position of the titles relative to each group with the ```@example using CairoMakie -scene, layout = layoutscene(resolution = (1400, 900)) +f = Figure() -ax = layout[1, 1] = Axis(scene) +Axis(f[1, 1]) markersizes = [5, 10, 15, 20] colors = [:red, :green, :blue, :orange] for ms in markersizes, color in colors - scatter!(ax, randn(5, 2), markersize = ms, color = color) + scatter!(randn(5, 2), markersize = ms, color = color) end group_size = [MarkerElement(marker = :circle, color = :black, strokecolor = :transparent, @@ -255,13 +248,13 @@ group_size = [MarkerElement(marker = :circle, color = :black, strokecolor = :tra group_color = [PolyElement(color = color, strokecolor = :transparent) for color in colors] -legends = [Legend(scene, +legends = [Legend(f, [group_size, group_color], [string.(markersizes), string.(colors)], ["Size", "Color"]) for _ in 1:6] -layout[1, 2:4] = legends[1:3] -layout[2:4, 1] = legends[4:6] +f[1, 2:4] = legends[1:3] +f[2:4, 2] = legends[4:6] for l in legends[4:6] l.orientation = :horizontal @@ -276,7 +269,7 @@ legends[3].nbanks = 2 legends[5].nbanks = 2 legends[6].nbanks = 2 -scene +f ``` ```@eval diff --git a/docs/src/makielayout/lscene.md b/docs/src/makielayout/lscene.md index e84932c1a..41fce07b5 100644 --- a/docs/src/makielayout/lscene.md +++ b/docs/src/makielayout/lscene.md @@ -17,7 +17,7 @@ are not inherited from the main scene (which has a pixel camera and no axis, e.g ```julia using CairoMakie -fig = Figure(resolution = (1200, 900)) +fig = Figure() lscene = LScene(fig[1, 1], scenekw = (camera = cam3d!, raw = false)) diff --git a/docs/src/makielayout/menu.md b/docs/src/makielayout/menu.md index 2316b6d87..6881a1709 100644 --- a/docs/src/makielayout/menu.md +++ b/docs/src/makielayout/menu.md @@ -16,7 +16,7 @@ The attribute `selection` is set to `optionvalue(element)` when the element's en ```@example using GLMakie -fig = Figure(resolution = (1200, 900)) +fig = Figure() menu = Menu(fig, options = ["viridis", "heat", "blues"]) @@ -38,7 +38,7 @@ func = Node{Any}(funcs[1]) ys = @lift($func.(0:0.3:10)) scat = scatter!(ax, ys, markersize = 10px, color = ys) -cb = Colorbar(fig[1, 3], scat, width = 30) +cb = Colorbar(fig[1, 3], scat) on(menu.selection) do s scat.colormap = s diff --git a/docs/src/makielayout/slider.md b/docs/src/makielayout/slider.md index 528a8f51d..3128fcc2d 100644 --- a/docs/src/makielayout/slider.md +++ b/docs/src/makielayout/slider.md @@ -20,7 +20,7 @@ If you set the attribute `snap = false`, the slider will move continously while ```@example using GLMakie -fig = Figure(resolution = (1200, 900)) +fig = Figure() ax = Axis(fig[1, 1]) @@ -45,7 +45,7 @@ To create a horizontal layout containing a label, a slider, and a value label, u ```@example using GLMakie -fig = Figure(resolution = (1200, 900)) +fig = Figure() ax = Axis(fig[1, 1]) diff --git a/docs/src/makielayout/toggle.md b/docs/src/makielayout/toggle.md index cb883d441..d497e7d6c 100644 --- a/docs/src/makielayout/toggle.md +++ b/docs/src/makielayout/toggle.md @@ -11,7 +11,7 @@ or disable properties of an interactive plot. ```@example using GLMakie -fig = Figure(resolution = (1200, 900)) +fig = Figure() ax = Axis(fig[1, 1]) diff --git a/docs/src/makielayout/tutorial.md b/docs/src/makielayout/tutorial.md index 2d1961a43..4cf8f03a5 100755 --- a/docs/src/makielayout/tutorial.md +++ b/docs/src/makielayout/tutorial.md @@ -43,7 +43,8 @@ Random.seed!(2) # hide noto_sans = "../assets/NotoSans-Regular.ttf" noto_sans_bold = "../assets/NotoSans-Bold.ttf" -fig = Figure(resolution = (1200, 700), backgroundcolor = RGBf0(0.98, 0.98, 0.98), font = noto_sans) +fig = Figure(backgroundcolor = RGBf0(0.98, 0.98, 0.98), + resolution = (1000, 700), font = noto_sans) fig ``` @@ -337,21 +338,7 @@ cbar = hm_sublayout[:, 2] = Colorbar(fig, heatmaps[1], label = "Activity [spikes fig ``` - -The color bar is quite chunky because it takes 50% of the available width in the -sublayout. Let's give it a fixed width of 30 units. - -```@example tutorial -cbar.width = 30 - -fig -``` - - -Much better! Note that you can usually set all attributes during creation of an object -(`Colorbar(fig, width = 30)`) or after the fact, like in this example. - -Objects can also have a width or height relative to the space given to them by their +Objects can have a width or height relative to the space given to them by their parent `GridLayout`. If we feel that the colorbar is a bit too tall, we can shrink it to two thirds of the available height using `Relative(2/3)`. @@ -393,7 +380,7 @@ to reflect the new GridLayout size. ```@example tutorial supertitle = fig[0, :] = Label(fig, "Complex Figures with Makie", - textsize = 30, font = noto_sans_bold, color = (:black, 0.25)) + textsize = 24, font = noto_sans_bold, color = (:black, 0.25)) fig ``` @@ -428,9 +415,9 @@ choice. (Remember that our previously first row is now the second row, due to th super title.) ```@example tutorial -label_a = fig[2, 1, TopLeft()] = Label(fig, "A", textsize = 35, +label_a = fig[2, 1, TopLeft()] = Label(fig, "A", textsize = 24, font = noto_sans_bold, halign = :right) -label_b = fig[2, 3, TopLeft()] = Label(fig, "B", textsize = 35, +label_b = fig[2, 3, TopLeft()] = Label(fig, "B", textsize = 24, font = noto_sans_bold, halign = :right) fig diff --git a/docs/src/plot_method_signatures.md b/docs/src/plot_method_signatures.md index 92ceff499..c2b8380b2 100644 --- a/docs/src/plot_method_signatures.md +++ b/docs/src/plot_method_signatures.md @@ -78,7 +78,7 @@ If a GridLayout along the nesting levels doesn't exist, yet, it is created autom ```@example using GLMakie -fig = Figure(resolution = (1200, 900)) +fig = Figure() # first row, first column scatter(fig[1, 1], 1.0..10, sin) @@ -96,7 +96,7 @@ lines(fig[1, 3][2, 1], cumsum(randn(1000)), color = :red) ax, hm = heatmap(fig[2, 1:3], randn(30, 10)) # across all rows, new column after the last one -fig[:, end+1] = Colorbar(fig, hm, width = 30) +fig[:, end+1] = Colorbar(fig, hm) fig ``` diff --git a/docs/src/plotting_functions/arrows.md b/docs/src/plotting_functions/arrows.md index 7ccf05342..1b86b911c 100644 --- a/docs/src/plotting_functions/arrows.md +++ b/docs/src/plotting_functions/arrows.md @@ -11,7 +11,7 @@ using GLMakie GLMakie.activate!() # hide AbstractPlotting.inline!(true) # hide -f = Figure(resolution = (800, 600)) +f = Figure() Axis(f[1, 1]) xs = LinRange(1, 10, 20) diff --git a/docs/src/plotting_functions/band.md b/docs/src/plotting_functions/band.md index c306b57ec..898aa2e66 100644 --- a/docs/src/plotting_functions/band.md +++ b/docs/src/plotting_functions/band.md @@ -11,7 +11,7 @@ using CairoMakie CairoMakie.activate!() # hide AbstractPlotting.inline!(true) # hide -f = Figure(resolution = (800, 600)) +f = Figure() Axis(f[1, 1]) xs = 1:0.2:10 @@ -31,7 +31,7 @@ using CairoMakie CairoMakie.activate!() # hide AbstractPlotting.inline!(true) # hide -f = Figure(resolution = (800, 600)) +f = Figure() Axis(f[1, 1]) n, m = 100, 101 diff --git a/docs/src/plotting_functions/barplot.md b/docs/src/plotting_functions/barplot.md index 5d947a473..e6a36453c 100644 --- a/docs/src/plotting_functions/barplot.md +++ b/docs/src/plotting_functions/barplot.md @@ -11,7 +11,7 @@ using CairoMakie CairoMakie.activate!() # hide AbstractPlotting.inline!(true) # hide -f = Figure(resolution = (800, 600)) +f = Figure() Axis(f[1, 1]) xs = 1:0.2:10 @@ -53,7 +53,6 @@ barplot(tbl.x, tbl.height, color = tbl.grp, axis = (xticks = (1:3, ["left", "middle", "right"]), title = "Stacked bars"), - figure = (resolution = (800, 600), ) ) ``` @@ -63,7 +62,6 @@ barplot(tbl.x, tbl.height, color = tbl.grp, axis = (xticks = (1:3, ["left", "middle", "right"]), title = "Dodged bars"), - figure = (resolution = (800, 600), ) ) ``` @@ -74,7 +72,6 @@ barplot(tbl.x, tbl.height, color = tbl.grp, axis = (xticks = (1:3, ["left", "middle", "right"]), title = "Dodged and stacked bars"), - figure = (resolution = (800, 600), ) ) ``` @@ -83,7 +80,7 @@ let colors = AbstractPlotting.wong_colors # Figure and Axis - fig = Figure(resolution = (800, 600)) + fig = Figure() ax = Axis(fig[1,1], xticks = (1:3, ["left", "middle", "right"]), title = "Dodged bars with legend") diff --git a/docs/src/plotting_functions/contour.md b/docs/src/plotting_functions/contour.md index d4ce8314b..7cec6ae96 100644 --- a/docs/src/plotting_functions/contour.md +++ b/docs/src/plotting_functions/contour.md @@ -11,7 +11,7 @@ using CairoMakie CairoMakie.activate!() # hide AbstractPlotting.inline!(true) # hide -f = Figure(resolution = (800, 600)) +f = Figure() Axis(f[1, 1]) xs = LinRange(0, 10, 100) diff --git a/docs/src/plotting_functions/contourf.md b/docs/src/plotting_functions/contourf.md index 143486206..59463eb3b 100644 --- a/docs/src/plotting_functions/contourf.md +++ b/docs/src/plotting_functions/contourf.md @@ -13,12 +13,12 @@ xs = LinRange(0, 10, 100) ys = LinRange(0, 10, 100) zs = [cos(x) * sin(y) for x in xs, y in ys] -f = Figure(resolution = (800, 600)) +f = Figure() Axis(f[1, 1]) co = contourf!(xs, ys, zs, levels = 10) -Colorbar(f[1, 2], co, width = 20) +Colorbar(f[1, 2], co) f ``` @@ -33,13 +33,13 @@ xs = LinRange(0, 10, 100) ys = LinRange(0, 10, 100) zs = [cos(x) * sin(y) for x in xs, y in ys] -f = Figure(resolution = (800, 600)) +f = Figure() Axis(f[1, 1]) co = contourf!(xs, ys, zs, levels = -0.75:0.25:0.5, extendlow = :cyan, extendhigh = :magenta) -Colorbar(f[1, 2], co, width = 20) +Colorbar(f[1, 2], co) f ``` @@ -54,14 +54,14 @@ xs = LinRange(0, 10, 100) ys = LinRange(0, 10, 100) zs = [cos(x) * sin(y) for x in xs, y in ys] -f = Figure(resolution = (800, 600)) +f = Figure() Axis(f[1, 1]) co = contourf!(xs, ys, zs, levels = -0.75:0.25:0.5, extendlow = :auto, extendhigh = :auto) -Colorbar(f[1, 2], co, width = 20) +Colorbar(f[1, 2], co) f ``` diff --git a/docs/src/plotting_functions/density.md b/docs/src/plotting_functions/density.md index 1cd988fce..3dc38c698 100644 --- a/docs/src/plotting_functions/density.md +++ b/docs/src/plotting_functions/density.md @@ -11,7 +11,7 @@ using CairoMakie CairoMakie.activate!() # hide AbstractPlotting.inline!(true) # hide -f = Figure(resolution = (800, 600)) +f = Figure() Axis(f[1, 1]) density!(randn(200)) @@ -25,7 +25,7 @@ using CairoMakie CairoMakie.activate!() # hide AbstractPlotting.inline!(true) # hide -f = Figure(resolution = (800, 600)) +f = Figure() Axis(f[1, 1]) density!(randn(200), direction = :y, npoints = 10) @@ -39,7 +39,7 @@ using CairoMakie CairoMakie.activate!() # hide AbstractPlotting.inline!(true) # hide -f = Figure(resolution = (800, 600)) +f = Figure() Axis(f[1, 1]) density!(randn(200), color = (:red, 0.3), @@ -54,7 +54,7 @@ using CairoMakie CairoMakie.activate!() # hide AbstractPlotting.inline!(true) # hide -f = Figure(resolution = (800, 600)) +f = Figure() Axis(f[1, 1]) vectors = [randn(1000) .+ i/2 for i in 0:5] diff --git a/docs/src/plotting_functions/errorbars.md b/docs/src/plotting_functions/errorbars.md index d7584c11b..1fe94ffaa 100644 --- a/docs/src/plotting_functions/errorbars.md +++ b/docs/src/plotting_functions/errorbars.md @@ -11,7 +11,7 @@ using CairoMakie CairoMakie.activate!() # hide AbstractPlotting.inline!(true) # hide -f = Figure(resolution = (800, 600)) +f = Figure() Axis(f[1, 1]) xs = 0:0.5:10 @@ -34,7 +34,7 @@ using CairoMakie CairoMakie.activate!() # hide AbstractPlotting.inline!(true) # hide -f = Figure(resolution = (800, 600)) +f = Figure() Axis(f[1, 1]) xs = 0:0.5:10 @@ -57,7 +57,7 @@ using CairoMakie CairoMakie.activate!() # hide AbstractPlotting.inline!(true) # hide -f = Figure(resolution = (800, 600)) +f = Figure() Axis(f[1, 1]) xs = 0:0.5:10 diff --git a/docs/src/plotting_functions/heatmap.md b/docs/src/plotting_functions/heatmap.md index a133f3ea1..d129c1b9e 100644 --- a/docs/src/plotting_functions/heatmap.md +++ b/docs/src/plotting_functions/heatmap.md @@ -12,7 +12,7 @@ CairoMakie.activate!() # hide AbstractPlotting.inline!(true) # hide -f = Figure(resolution = (800, 600)) +f = Figure() Axis(f[1, 1]) xs = LinRange(0, 10, 25) diff --git a/docs/src/plotting_functions/image.md b/docs/src/plotting_functions/image.md index d8353c804..ffcc0b158 100644 --- a/docs/src/plotting_functions/image.md +++ b/docs/src/plotting_functions/image.md @@ -14,7 +14,7 @@ using FileIO img = rotr90(load("../assets/cow.png")) -f = Figure(resolution = (800, 600)) +f = Figure() Axis(f[1, 1], aspect = DataAspect()) image!(img) diff --git a/docs/src/plotting_functions/lines.md b/docs/src/plotting_functions/lines.md index 3f9afbf1a..792fa7547 100644 --- a/docs/src/plotting_functions/lines.md +++ b/docs/src/plotting_functions/lines.md @@ -11,7 +11,7 @@ using CairoMakie CairoMakie.activate!() # hide AbstractPlotting.inline!(true) # hide -f = Figure(resolution = (800, 600)) +f = Figure() Axis(f[1, 1]) xs = 0:0.01:10 diff --git a/docs/src/plotting_functions/linesegments.md b/docs/src/plotting_functions/linesegments.md index 5fd64a239..a10cd7420 100644 --- a/docs/src/plotting_functions/linesegments.md +++ b/docs/src/plotting_functions/linesegments.md @@ -11,7 +11,7 @@ using CairoMakie CairoMakie.activate!() # hide AbstractPlotting.inline!(true) # hide -f = Figure(resolution = (800, 600)) +f = Figure() Axis(f[1, 1]) xs = 1:0.2:10 diff --git a/docs/src/plotting_functions/poly.md b/docs/src/plotting_functions/poly.md index d48efa521..189dd79eb 100644 --- a/docs/src/plotting_functions/poly.md +++ b/docs/src/plotting_functions/poly.md @@ -12,7 +12,7 @@ CairoMakie.activate!() # hide using AbstractPlotting.GeometryBasics AbstractPlotting.inline!(true) # hide -f = Figure(resolution = (800, 600)) +f = Figure() Axis(f[1, 1]) poly!(Point2f0[(0, 0), (2, 0), (3, 1), (1, 1)], color = :red, strokecolor = :black, strokewidth = 1) @@ -27,7 +27,7 @@ CairoMakie.activate!() # hide using AbstractPlotting.GeometryBasics AbstractPlotting.inline!(true) # hide -f = Figure(resolution = (800, 600)) +f = Figure() Axis(f[1, 1]) # polygon with hole @@ -48,7 +48,7 @@ CairoMakie.activate!() # hide using AbstractPlotting.GeometryBasics AbstractPlotting.inline!(true) # hide -f = Figure(resolution = (800, 600)) +f = Figure() Axis(f[1, 1]) # vector of shapes @@ -69,7 +69,7 @@ CairoMakie.activate!() # hide using AbstractPlotting.GeometryBasics AbstractPlotting.inline!(true) # hide -f = Figure(resolution = (800, 600)) +f = Figure() Axis(f[1, 1], aspect = DataAspect()) # shape decomposition @@ -85,7 +85,7 @@ CairoMakie.activate!() # hide using AbstractPlotting.GeometryBasics AbstractPlotting.inline!(true) # hide -f = Figure(resolution = (800, 600)) +f = Figure() Axis(f[1, 1]) # vector of polygons diff --git a/docs/src/plotting_functions/rangebars.md b/docs/src/plotting_functions/rangebars.md index ea24eb4f4..bdc781472 100644 --- a/docs/src/plotting_functions/rangebars.md +++ b/docs/src/plotting_functions/rangebars.md @@ -11,7 +11,7 @@ using CairoMakie CairoMakie.activate!() # hide AbstractPlotting.inline!(true) # hide -f = Figure(resolution = (800, 600)) +f = Figure() Axis(f[1, 1]) vals = -1:0.1:1 @@ -29,7 +29,7 @@ using CairoMakie CairoMakie.activate!() # hide AbstractPlotting.inline!(true) # hide -f = Figure(resolution = (800, 600)) +f = Figure() Axis(f[1, 1]) vals = -1:0.1:1 diff --git a/docs/src/plotting_functions/scatter.md b/docs/src/plotting_functions/scatter.md index 6483e750a..094cf1ff1 100644 --- a/docs/src/plotting_functions/scatter.md +++ b/docs/src/plotting_functions/scatter.md @@ -11,7 +11,7 @@ using CairoMakie CairoMakie.activate!() # hide AbstractPlotting.inline!(true) # hide -f = Figure(resolution = (800, 600)) +f = Figure() Axis(f[1, 1]) xs = LinRange(0, 10, 20) diff --git a/docs/src/plotting_functions/scatterlines.md b/docs/src/plotting_functions/scatterlines.md index 869903c36..2cc18ed3f 100644 --- a/docs/src/plotting_functions/scatterlines.md +++ b/docs/src/plotting_functions/scatterlines.md @@ -11,7 +11,7 @@ using CairoMakie CairoMakie.activate!() # hide AbstractPlotting.inline!(true) # hide -f = Figure(resolution = (800, 600)) +f = Figure() Axis(f[1, 1]) xs = LinRange(0, 10, 20) diff --git a/docs/src/plotting_functions/stem.md b/docs/src/plotting_functions/stem.md index 6fc9769fc..3cbd2cff0 100644 --- a/docs/src/plotting_functions/stem.md +++ b/docs/src/plotting_functions/stem.md @@ -11,7 +11,7 @@ using CairoMakie CairoMakie.activate!() # hide AbstractPlotting.inline!(true) # hide -f = Figure(resolution = (800, 600)) +f = Figure() Axis(f[1, 1]) xs = LinRange(0, 4pi, 30) @@ -27,7 +27,7 @@ using CairoMakie CairoMakie.activate!() # hide AbstractPlotting.inline!(true) # hide -f = Figure(resolution = (800, 600)) +f = Figure() Axis(f[1, 1]) xs = LinRange(0, 4pi, 30) @@ -47,7 +47,7 @@ using CairoMakie CairoMakie.activate!() # hide AbstractPlotting.inline!(true) # hide -f = Figure(resolution = (800, 600)) +f = Figure() Axis(f[1, 1]) xs = LinRange(0, 4pi, 30) @@ -66,7 +66,7 @@ using GLMakie GLMakie.activate!() # hide AbstractPlotting.inline!(true) # hide -f = Figure(resolution = (800, 600)) +f = Figure() xs = LinRange(0, 4pi, 30) diff --git a/docs/src/plotting_functions/streamplot.md b/docs/src/plotting_functions/streamplot.md index 4796b3ccb..eff711f2b 100644 --- a/docs/src/plotting_functions/streamplot.md +++ b/docs/src/plotting_functions/streamplot.md @@ -27,8 +27,7 @@ f(x, P::FitzhughNagumo) = Point2f0( f(x) = f(x, P) -streamplot(f, -1.5..1.5, -1.5..1.5, colormap = :magma, - figure = (resolution = (800, 600),)) +streamplot(f, -1.5..1.5, -1.5..1.5, colormap = :magma) save("example_streamplot.png", current_figure(), px_per_unit = 2); nothing # hide ``` diff --git a/docs/src/plotting_functions/text.md b/docs/src/plotting_functions/text.md index 41d3151f5..59e7553b2 100644 --- a/docs/src/plotting_functions/text.md +++ b/docs/src/plotting_functions/text.md @@ -18,7 +18,7 @@ using CairoMakie CairoMakie.activate!() # hide AbstractPlotting.inline!(true) # hide -f = Figure(resolution = (800, 600)) +f = Figure() Axis(f[1, 1], aspect = DataAspect(), backgroundcolor = :gray50) @@ -46,7 +46,7 @@ using CairoMakie CairoMakie.activate!() # hide AbstractPlotting.inline!(true) # hide -f = Figure(resolution = (800, 600)) +f = Figure() LScene(f[1, 1]) text!( @@ -112,7 +112,7 @@ using CairoMakie CairoMakie.activate!() # hide AbstractPlotting.inline!(true) # hide -f = Figure(resolution = (800, 600)) +f = Figure() horsepower = [52, 78, 80, 112, 140] cars = ["Kia", "Mini", "Honda", "Mercedes", "Ferrari"] diff --git a/docs/src/recipes.md b/docs/src/recipes.md index e6453bc42..f19081cd6 100644 --- a/docs/src/recipes.md +++ b/docs/src/recipes.md @@ -255,7 +255,7 @@ stockvalues = foldl(timestamps[2:end], init = [startvalue]) do values, t end # now we can use our new recipe -f = Figure(resolution = (1200, 900)) +f = Figure() stockchart(f[1, 1], timestamps, stockvalues) diff --git a/docs/src/theming.md b/docs/src/theming.md index 14d8cb89e..17f697001 100644 --- a/docs/src/theming.md +++ b/docs/src/theming.md @@ -12,7 +12,7 @@ Let's create a plot with the default theme: using GLMakie function example_plot() - f = Figure(resolution = (1000, 800)) + f = Figure() for i in 1:2, j in 1:2 lines(f[i, j], cumsum(randn(1000))) end diff --git a/src/display.jl b/src/display.jl index 348ec75db..c27defa09 100644 --- a/src/display.jl +++ b/src/display.jl @@ -109,22 +109,9 @@ function Base.show(io::IO, m::MIME, scene::Scene) # this just indicates, that now we may update on e.g. resize update!(scene) - # Here, we deal with the Juno plotsize. - # Since SVGs are in units of pt, which is 1/72 in, - # and pixels (which Juno reports its plotsize as) - # are 1/96 in, we need to rescale the scene, - # whose units are in pt, into the expected size in px. - # This means we have to scale by a factor of 72/96. - res = get(io, :juno_plotsize, nothing) - if !isnothing(res) - if m isa MIME"image/svg+xml" - res = round.(Int, res .* 0.75) - end - resize!(scene, res...) - end ioc = IOContext(io, :full_fidelity => true, - :pt_per_unit => get(io, :pt_per_unit, 1.0), + :pt_per_unit => get(io, :pt_per_unit, 0.75), :px_per_unit => get(io, :px_per_unit, 1.0) ) screen = backend_show(current_backend[], ioc, m, scene) @@ -204,7 +191,7 @@ filetype(::FileIO.File{F}) where F = F """ - FileIO.save(filename, scene; resolution = size(scene), pt_per_unit = 1.0, px_per_unit = 1.0) + FileIO.save(filename, scene; resolution = size(scene), pt_per_unit = 0.75, px_per_unit = 1.0) Save a `Scene` with the specified filename and format. @@ -234,7 +221,7 @@ end function FileIO.save( file::FileIO.Formatted, fig::FigureLike; resolution = size(get_scene(fig)), - pt_per_unit = 1.0, + pt_per_unit = 0.75, px_per_unit = 1.0, ) scene = get_scene(fig) diff --git a/src/figures.jl b/src/figures.jl index d389597b1..a747b665e 100644 --- a/src/figures.jl +++ b/src/figures.jl @@ -59,8 +59,28 @@ function current_axis!(ax) ax end +to_rectsides(n::Number) = to_rectsides((n, n, n, n)) +to_rectsides(t::Tuple{Any, Any, Any, Any}) = GridLayoutBase.RectSides{Float32}(t...) + function Figure(; kwargs...) - scene, layout = layoutscene(; kwargs...) + + kwargs_dict = Dict(kwargs) + padding = pop!(kwargs_dict, :figure_padding, current_default_theme()[:figure_padding]) + + scene = Scene(; camera = campixel!, kwargs_dict...) + + padding = padding isa Observable ? padding : Observable{Any}(padding) + + alignmode = lift(Outside ∘ to_rectsides, padding) + + layout = GridLayout(scene) + + on(alignmode) do al + layout.alignmode[] = al + notify(layout.needs_update) + end + notify(alignmode) + Figure( scene, layout, diff --git a/src/interfaces.jl b/src/interfaces.jl index 6a09dc7d6..3b48a7c66 100644 --- a/src/interfaces.jl +++ b/src/interfaces.jl @@ -211,7 +211,7 @@ $(ATTRIBUTES) colormap = :viridis, colorrange = automatic, marker = Circle, - markersize = 10, + markersize = 8, strokecolor = :black, strokewidth = 1.0, diff --git a/src/makielayout/defaultattributes.jl b/src/makielayout/defaultattributes.jl index 5b2fac192..9a5bb71d1 100644 --- a/src/makielayout/defaultattributes.jl +++ b/src/makielayout/defaultattributes.jl @@ -22,9 +22,9 @@ function default_attributes(::Type{Axis}, scene) "The font family of the title." titlefont = lift_parent_attribute(scene, :font, "DejaVu Sans") "The title's font size." - titlesize = lift_parent_attribute(scene, :fontsize, 20f0) + titlesize = lift_parent_attribute(scene, :fontsize, 16f0) "The gap between axis and title." - titlegap = 10f0 + titlegap = 4f0 "Controls if the title is visible." titlevisible = true "The horizontal alignment of the title." @@ -40,17 +40,17 @@ function default_attributes(::Type{Axis}, scene) "The color of the ylabel." ylabelcolor = RGBf0(0, 0, 0) "The font size of the xlabel." - xlabelsize = lift_parent_attribute(scene, :fontsize, 20f0) + xlabelsize = lift_parent_attribute(scene, :fontsize, 16f0) "The font size of the ylabel." - ylabelsize = lift_parent_attribute(scene, :fontsize, 20f0) + ylabelsize = lift_parent_attribute(scene, :fontsize, 16f0) "Controls if the xlabel is visible." xlabelvisible = true "Controls if the ylabel is visible." ylabelvisible = true "The padding between the xlabel and the ticks or axis." - xlabelpadding = 15f0 + xlabelpadding = 3f0 "The padding between the ylabel and the ticks or axis." - ylabelpadding = 15f0 # because of boundingbox inaccuracies of ticklabels + ylabelpadding = 5f0 # because of boundingbox inaccuracies of ticklabels "The font family of the xticklabels." xticklabelfont = lift_parent_attribute(scene, :font, "DejaVu Sans") "The font family of the yticklabels." @@ -60,9 +60,9 @@ function default_attributes(::Type{Axis}, scene) "The color of yticklabels." yticklabelcolor = RGBf0(0, 0, 0) "The font size of the xticklabels." - xticklabelsize = lift_parent_attribute(scene, :fontsize, 20f0) + xticklabelsize = lift_parent_attribute(scene, :fontsize, 16f0) "The font size of the yticklabels." - yticklabelsize = lift_parent_attribute(scene, :fontsize, 20f0) + yticklabelsize = lift_parent_attribute(scene, :fontsize, 16f0) "Controls if the xticklabels are visible." xticklabelsvisible = true "Controls if the yticklabels are visible." @@ -72,9 +72,9 @@ function default_attributes(::Type{Axis}, scene) "The space reserved for the yticklabels." yticklabelspace = AbstractPlotting.automatic "The space between xticks and xticklabels." - xticklabelpad = 5f0 + xticklabelpad = 2f0 "The space between yticks and yticklabels." - yticklabelpad = 5f0 + yticklabelpad = 4f0 "The counterclockwise rotation of the xticklabels in radians." xticklabelrotation = 0f0 "The counterclockwise rotation of the yticklabels in radians." @@ -84,9 +84,9 @@ function default_attributes(::Type{Axis}, scene) "The horizontal and vertical alignment of the yticklabels." yticklabelalign = AbstractPlotting.automatic "The size of the xtick marks." - xticksize = 10f0 + xticksize = 6f0 "The size of the ytick marks." - yticksize = 10f0 + yticksize = 6f0 "Controls if the xtick marks are visible." xticksvisible = true "Controls if the ytick marks are visible." @@ -228,7 +228,7 @@ function default_attributes(::Type{Axis}, scene) "The alignment of x minor ticks on the axis spine" xminortickalign = 0f0 "The tick size of x minor ticks" - xminorticksize = 5f0 + xminorticksize = 4f0 "The tick width of x minor ticks" xminortickwidth = 1f0 "The tick color of x minor ticks" @@ -240,7 +240,7 @@ function default_attributes(::Type{Axis}, scene) "The alignment of y minor ticks on the axis spine" yminortickalign = 0f0 "The tick size of y minor ticks" - yminorticksize = 5f0 + yminorticksize = 4f0 "The tick width of y minor ticks" yminortickwidth = 1f0 "The tick color of y minor ticks" @@ -275,21 +275,21 @@ function default_attributes(::Type{Colorbar}, scene) "The label font family." labelfont = lift_parent_attribute(scene, :font, "DejaVu Sans") "The label font size." - labelsize = lift_parent_attribute(scene, :fontsize, 20f0) + labelsize = lift_parent_attribute(scene, :fontsize, 16f0) "Controls if the label is visible." labelvisible = true "The gap between the label and the ticks." - labelpadding = 15f0 + labelpadding = 5f0 "The font family of the tick labels." ticklabelfont = lift_parent_attribute(scene, :font, "DejaVu Sans") "The font size of the tick labels." - ticklabelsize = lift_parent_attribute(scene, :fontsize, 20f0) + ticklabelsize = lift_parent_attribute(scene, :fontsize, 16f0) "Controls if the tick labels are visible." ticklabelsvisible = true "The color of the tick labels." ticklabelcolor = RGBf0(0, 0, 0) "The size of the tick marks." - ticksize = 10f0 + ticksize = 6f0 "Controls if the tick marks are visible." ticksvisible = true "The ticks." @@ -299,7 +299,7 @@ function default_attributes(::Type{Colorbar}, scene) "The space reserved for the tick labels." ticklabelspace = AbstractPlotting.automatic "The gap between tick labels and tick marks." - ticklabelpad = 5f0 + ticklabelpad = 3f0 "The alignment of the tick marks relative to the axis spine (0 = out, 1 = in)." tickalign = 0f0 "The line width of the tick marks." @@ -363,7 +363,7 @@ function default_attributes(::Type{Colorbar}, scene) "The alignment of minor ticks on the axis spine" minortickalign = 0f0 "The tick size of minor ticks" - minorticksize = 5f0 + minorticksize = 4f0 "The tick width of minor ticks" minortickwidth = 1f0 "The tick color of minor ticks" @@ -373,7 +373,7 @@ function default_attributes(::Type{Colorbar}, scene) "The axis scale" scale = identity "The width or height of the colorbar, depending on if it's vertical or horizontal, unless overridden by `width` / `height`" - size = 20 + size = 16 end (attributes = attrs, documentation = docdict, defaults = defaultdict) end @@ -404,7 +404,7 @@ function default_attributes(::Type{Label}, scene) "The color of the text." color = RGBf0(0, 0, 0) "The font size of the text." - textsize = lift_parent_attribute(scene, :fontsize, 20f0) + textsize = lift_parent_attribute(scene, :fontsize, 16f0) "The font family of the text." font = lift_parent_attribute(scene, :font, "DejaVu Sans") "The vertical alignment of the text in its suggested boundingbox" @@ -491,7 +491,7 @@ function default_attributes(::Type{Button}, scene) "The extra space added to the sides of the button label's boundingbox." padding = (10f0, 10f0, 10f0, 10f0) "The font size of the button label." - textsize = lift_parent_attribute(scene, :fontsize, 20f0) + textsize = lift_parent_attribute(scene, :fontsize, 16f0) "The text of the button label." label = "Button" "The font family of the button label." @@ -549,7 +549,7 @@ function default_attributes(::Type{LineAxis}) limits = (0f0, 100f0), flipped = false, flip_vertical_label = false, - ticksize = 10f0, + ticksize = 6f0, tickwidth = 1f0, tickcolor = RGBf0(0, 0, 0), tickalign = 0f0, @@ -567,12 +567,12 @@ function default_attributes(::Type{LineAxis}) labelcolor = RGBf0(0, 0, 0), labelvisible = true, ticklabelspace = AbstractPlotting.automatic, - ticklabelpad = 5f0, - labelpadding = 15f0, + ticklabelpad = 3f0, + labelpadding = 5f0, reversed = false, minorticksvisible = true, minortickalign = 0f0, - minorticksize = 5f0, + minorticksize = 4f0, minortickwidth = 1f0, minortickcolor = :black, minorticks = AbstractPlotting.automatic, @@ -742,7 +742,7 @@ function default_attributes(::Type{Legend}, scene) "The font family of the legend group titles." titlefont = lift_parent_attribute(scene, :font, "DejaVu Sans") "The font size of the legend group titles." - titlesize = lift_parent_attribute(scene, :fontsize, 20f0) + titlesize = lift_parent_attribute(scene, :fontsize, 16f0) "The horizontal alignment of the legend group titles." titlehalign = :center "The vertical alignment of the legend group titles." @@ -754,7 +754,7 @@ function default_attributes(::Type{Legend}, scene) "The group title positions relative to their groups. Can be `:top` or `:left`." titleposition = :top "The font size of the entry labels." - labelsize = lift_parent_attribute(scene, :fontsize, 20f0) + labelsize = lift_parent_attribute(scene, :fontsize, 16f0) "The font family of the entry labels." labelfont = lift_parent_attribute(scene, :font, "DejaVu Sans") "The color of the entry labels." @@ -764,7 +764,7 @@ function default_attributes(::Type{Legend}, scene) "The vertical alignment of the entry labels." labelvalign = :center "The additional space between the legend content and the border." - padding = (10f0, 10f0, 10f0, 10f0) + padding = (10f0, 10f0, 8f0, 8f0) "The additional space between the legend and its suggested boundingbox." margin = (0f0, 0f0, 0f0, 0f0) "The background color of the legend." @@ -788,9 +788,9 @@ function default_attributes(::Type{Legend}, scene) "The number of banks in which the legend entries are grouped. Columns if the legend is vertically oriented, otherwise rows." nbanks = 1 "The gap between the label of one legend entry and the patch of the next." - colgap = 20 + colgap = 16 "The gap between the entry rows." - rowgap = 4 + rowgap = 3 "The gap between the patch and the label of each legend entry." patchlabelgap = 5 "The default points used for LineElements in normalized coordinates relative to each label patch." @@ -810,9 +810,9 @@ function default_attributes(::Type{Legend}, scene) "The orientation of the legend (:horizontal or :vertical)." orientation = :vertical "The gap between each group title and its group." - titlegap = 15 + titlegap = 8 "The gap between each group and the next." - groupgap = 30 + groupgap = 16 "The horizontal alignment of entry groups in their parent GridLayout." gridshalign = :center "The vertical alignment of entry groups in their parent GridLayout." @@ -911,7 +911,7 @@ function default_attributes(::Type{Textbox}, scene) "Controls if the textbox is defocused when a string is submitted." defocus_on_submit = true "Text size." - textsize = lift_parent_attribute(scene, :fontsize, 20f0) + textsize = lift_parent_attribute(scene, :fontsize, 16f0) "Text color." textcolor = :black "Text color for the placeholder." @@ -1025,11 +1025,11 @@ function default_attributes(::Type{Axis3}, scene) "Controls if the z ticks are visible" zticksvisible = true "The x label size" - xlabelsize = lift_parent_attribute(scene, :fontsize, 20f0) + xlabelsize = lift_parent_attribute(scene, :fontsize, 16f0) "The y label size" - ylabelsize = lift_parent_attribute(scene, :fontsize, 20f0) + ylabelsize = lift_parent_attribute(scene, :fontsize, 16f0) "The z label size" - zlabelsize = lift_parent_attribute(scene, :fontsize, 20f0) + zlabelsize = lift_parent_attribute(scene, :fontsize, 16f0) "The x label font" xlabelfont = lift_parent_attribute(scene, :font, "DejaVu Sans") "The y label font" @@ -1061,11 +1061,11 @@ function default_attributes(::Type{Axis3}, scene) "The z ticklabel color" zticklabelcolor = :black "The x ticklabel size" - xticklabelsize = lift_parent_attribute(scene, :fontsize, 20f0) + xticklabelsize = lift_parent_attribute(scene, :fontsize, 16f0) "The y ticklabel size" - yticklabelsize = lift_parent_attribute(scene, :fontsize, 20f0) + yticklabelsize = lift_parent_attribute(scene, :fontsize, 16f0) "The z ticklabel size" - zticklabelsize = lift_parent_attribute(scene, :fontsize, 20f0) + zticklabelsize = lift_parent_attribute(scene, :fontsize, 16f0) "The x ticklabel font" xticklabelfont = lift_parent_attribute(scene, :font, "DejaVu Sans") "The y ticklabel font" @@ -1133,9 +1133,9 @@ function default_attributes(::Type{Axis3}, scene) "The font family of the title." titlefont = lift_parent_attribute(scene, :font, "DejaVu Sans") "The title's font size." - titlesize = lift_parent_attribute(scene, :fontsize, 20f0) + titlesize = lift_parent_attribute(scene, :fontsize, 16f0) "The gap between axis and title." - titlegap = 10f0 + titlegap = 4f0 "Controls if the title is visible." titlevisible = true "The horizontal alignment of the title." diff --git a/src/makielayout/layoutables/menu.jl b/src/makielayout/layoutables/menu.jl index af12e7a2c..ef26fbd2a 100644 --- a/src/makielayout/layoutables/menu.jl +++ b/src/makielayout/layoutables/menu.jl @@ -37,7 +37,7 @@ function default_attributes(::Type{Menu}, scene) "The list of options selectable in the menu. This can be any iterable of a mixture of strings and containers with one string and one other value. If an entry is just a string, that string is both label and selection. If an entry is a container with one string and one other value, the string is the label and the other value is the selection." options = ["no options"] "Font size of the cell texts" - textsize = lift_parent_attribute(scene, :fontsize, 20f0) + textsize = lift_parent_attribute(scene, :fontsize, 16f0) "Padding of entry texts" textpadding = (10, 10, 10, 10) "Color of entry texts" diff --git a/src/theming.jl b/src/theming.jl index 734585754..d3321ec4c 100644 --- a/src/theming.jl +++ b/src/theming.jl @@ -26,11 +26,6 @@ If the primary monitor can't be accessed, returns (1920, 1080) (full hd) """ function primary_resolution end -""" -Returns a reasonable resolution for the main monitor. -(right now just half the resolution of the main monitor) -""" -reasonable_resolution() = primary_resolution() .÷ 2 #= Conservative 7-color palette from Points of view: Color blindness, Bang Wong - Nature Methods @@ -57,13 +52,17 @@ const default_palettes = Attributes( const minimal_default = Attributes( palette = default_palettes, font = "Dejavu Sans", + padding = Vec3f0(0.05), + figure_padding = 16, + rowgap = 24, + colgap = 24, backgroundcolor = :white, color = :black, colormap = :viridis, marker = Circle, markersize = 0.1, linestyle = nothing, - resolution = reasonable_resolution(), + resolution = (800, 600), # 4/3 aspect ratio visible = true, clear = true, show_axis = true, @@ -77,7 +76,6 @@ const minimal_default = Attributes( axis_type = automatic, camera = automatic, limits = automatic, - padding = Vec3f0(0.05), raw = false, SSAO = Attributes( # enable = false,