From ccf70c3325cc8fb046e83c3c8f963b70171145d9 Mon Sep 17 00:00:00 2001 From: jkrumbiegel <22495855+jkrumbiegel@users.noreply.github.com> Date: Thu, 18 Mar 2021 21:22:04 +0100 Subject: [PATCH] jk/documenter master (#663) --- .github/workflows/docs.yml | 2 +- .gitignore | 1 + docs/.gitignore | 2 +- docs/src/faq.md | 8 +-- docs/src/figure.md | 4 -- docs/src/makielayout/axis.md | 37 +++------- docs/src/makielayout/box.md | 3 +- docs/src/makielayout/button.md | 4 -- docs/src/makielayout/colorbar.md | 7 -- docs/src/makielayout/gridlayout.md | 43 ++---------- docs/src/makielayout/label.md | 5 +- docs/src/makielayout/layoutables.md | 9 --- docs/src/makielayout/legend.md | 36 ++-------- docs/src/makielayout/menu.md | 4 +- docs/src/makielayout/slider.md | 8 +-- docs/src/makielayout/toggle.md | 4 +- docs/src/makielayout/tutorial.md | 75 +-------------------- docs/src/plotting_functions/band.md | 3 - docs/src/plotting_functions/barplot.md | 5 -- docs/src/plotting_functions/contour.md | 4 -- docs/src/plotting_functions/contourf.md | 9 --- docs/src/plotting_functions/density.md | 19 ------ docs/src/plotting_functions/errorbars.md | 12 ---- docs/src/plotting_functions/heatmap.md | 9 +-- docs/src/plotting_functions/image.md | 5 -- docs/src/plotting_functions/lines.md | 3 - docs/src/plotting_functions/linesegments.md | 5 -- docs/src/plotting_functions/poly.md | 14 ---- docs/src/plotting_functions/rangebars.md | 7 -- docs/src/plotting_functions/scatter.md | 4 -- docs/src/plotting_functions/scatterlines.md | 4 -- docs/src/plotting_functions/stem.md | 12 ---- docs/src/recipes.md | 3 - 33 files changed, 34 insertions(+), 336 deletions(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 288c3f052..be671c6c2 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -40,7 +40,7 @@ jobs: - name: Install binary dependencies run: sudo apt-get update && sudo apt-get install -y xorg-dev mesa-utils xvfb libgl1 freeglut3-dev libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libxext-dev - name: Install Julia dependencies - run: DISPLAY=:0 xvfb-run -s '-screen 0 1024x768x24' julia --project=docs -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()' + run: DISPLAY=:0 xvfb-run -s '-screen 0 1024x768x24' julia --project=docs -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.add(url = "https://github.com/JuliaDocs/Documenter.jl", rev = "master"); Pkg.instantiate()' - name: Build and deploy env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index 3b2efcdcc..052283a85 100644 --- a/.gitignore +++ b/.gitignore @@ -11,5 +11,6 @@ bluemarble-2048.png phases.0001_print.jpg **/._* Manifest.toml +!docs/Manifest.toml \.DS_Store diff --git a/docs/.gitignore b/docs/.gitignore index 213fba58b..931380812 100644 --- a/docs/.gitignore +++ b/docs/.gitignore @@ -17,7 +17,7 @@ src/generated *.zip tmax prec -Manifest.toml +#Manifest.toml src/assets/syntaxtheme.css diff --git a/docs/src/faq.md b/docs/src/faq.md index a2f61d526..c02f273f8 100644 --- a/docs/src/faq.md +++ b/docs/src/faq.md @@ -113,11 +113,9 @@ ax2 = layout[1, 1] = Axis(scene, title = "Placed in Layout") ax3 = Axis(scene, bbox = BBox(400, 800, 400, 800), title = "Placed at BBox(400, 800, 400, 800)") -save("faq_squashed_element.svg", scene); nothing # hide +scene ``` -![squashed elements](faq_squashed_element.svg) - ### Columns or rows are shrunk to the size of Text or another element @@ -141,11 +139,9 @@ layout[2, 1] = Axis(scene, title = "Expanded") layout[1, 2] = Label(scene, "tellheight = true", tellheight = true) layout[2, 2] = Label(scene, "tellheight = false", tellheight = false) -save("faq_shrunk_row.svg", scene); nothing # hide +scene ``` -![shrunk row](faq_shrunk_row.svg) - ```@eval using GLMakie GLMakie.activate!() diff --git a/docs/src/figure.md b/docs/src/figure.md index 8f4eff460..ac194c0b4 100644 --- a/docs/src/figure.md +++ b/docs/src/figure.md @@ -70,10 +70,8 @@ lines(pos2, cumsum(randn(100))) heatmap(f[1, 3], randn(10, 10)) f -save("figurepositions.svg", f); nothing # hide ``` -![figurepositions](figurepositions.svg) You can also index further into a `FigurePosition`, which creates a `FigureSubposition`. With `FigureSubposition`s you can describe positions in arbitrarily nested grid layouts. @@ -92,10 +90,8 @@ f[1, 2][1, 1] = Axis(f, title = "I'm nested") heatmap(f[1, 2][2, 1], randn(20, 20)) f -save("figurepositions_2.svg", f); nothing # hide ``` -![figurepositions_2](figurepositions_2.svg) All nested grid layouts that don't exist yet, but are needed for a nested plotting call, are created in the background automatically. diff --git a/docs/src/makielayout/axis.md b/docs/src/makielayout/axis.md index 104c86acb..8acc07758 100755 --- a/docs/src/makielayout/axis.md +++ b/docs/src/makielayout/axis.md @@ -18,11 +18,9 @@ scene, layout = layoutscene(resolution = (1200, 900)) ax = layout[1, 1] = Axis(scene, xlabel = "x label", ylabel = "y label", title = "Title") -save("basic_axis.svg", scene) # hide -nothing # hide +scene ``` -![basic axis](basic_axis.svg) ## Plotting Into an Axis @@ -35,8 +33,7 @@ that it is more convenient to save and manipulate the plot objects. ```@example laxis lineobject = lines!(ax, 0..10, sin, color = :red) -save("basic_axis_plotting.svg", scene) # hide -nothing # hide +scene ``` ![basic axis plotting](basic_axis_plotting.svg) @@ -74,8 +71,7 @@ ylims!(axes[4], (1, -1)) # as tuple, reversed limits!(axes[5], 0, 2pi, -1, 1) # x1, x2, y1, y2 limits!(axes[6], BBox(0, 2pi, -1, 1)) # as rectangle -save("example_axis_limits.svg", scene) # hide -nothing # hide +scene ``` ![axis limits](example_axis_limits.svg) @@ -157,12 +153,9 @@ axes[4].xtickformat = "{:.2f}ms" axes[4].xlabel = "Time" -save("example_axis_ticks.svg", scene) # hide -nothing # hide +scene ``` -![axis ticks](example_axis_ticks.svg) - ## Minor Ticks and Grids You can show minor ticks and grids by setting `x/yminorticksvisible = true` and `x/yminorgridvisible = true` which are off by default. @@ -192,11 +185,9 @@ fig = with_theme(theme) do yminorticks = IntervalsBetween(n+1)) for n in 1:4] fig end -save("example_minor_ticks.svg", fig) # hide -nothing # hide -``` -![minor ticks](example_minor_ticks.svg) +fig +``` ## Hiding Axis Spines and Decorations @@ -217,11 +208,9 @@ ax2 = layout[1, 2] = Axis(scene, title = "Axis 2") hidespines!(ax1) hidespines!(ax2, :t, :r) # only top and right -save("example_axis_hidespines.svg", scene) # hide -nothing # hide +scene ``` -![axis hide spines](example_axis_hidespines.svg) To hide decorations, you can use `hidedecorations!`, or the specific `hidexdecorations!` and `hideydecorations!`. When hiding, you can set `label = false`, `ticklabels = false`, `ticks = false`, `grid = false`, `minorgrid = false` or `minorticks = false` as keyword @@ -277,12 +266,9 @@ axes[2, 2].aspect = AxisAspect(2) axes[2, 3].title = "AxisAspect(0.5)" axes[2, 3].aspect = AxisAspect(0.5) -save("example_axis_aspects.svg", scene) # hide -nothing # hide +scene ``` -![axis aspects](example_axis_aspects.svg) - ## Controlling Data Aspect Ratios @@ -386,12 +372,9 @@ for i in 1:3 end end -save("example_linked_axes.svg", scene) # hide -nothing # hide +scene ``` -![linked axes](example_linked_axes.svg) - ## Axis interaction @@ -526,10 +509,8 @@ ax2 = layout[1, 2] = Axis(scene, title = "hlines") hlines!(ax2, [1, 2, 3, 4], xmax = [0.25, 0.5, 0.75, 1], color = :blue) scene -save("example_vlines.svg", scene); nothing # hide ``` -![example vlines](example_vlines.svg) ```@eval using GLMakie diff --git a/docs/src/makielayout/box.md b/docs/src/makielayout/box.md index 0133facee..f00f8930d 100644 --- a/docs/src/makielayout/box.md +++ b/docs/src/makielayout/box.md @@ -18,7 +18,6 @@ rects = fig[1:4, 1:6] = [ Box(fig, color = c) for c in get.(Ref(ColorSchemes.rainbow), (0:23) ./ 23)] -save("example_lrect.svg", fig); nothing # hide +fig ``` -![example lrect](example_lrect.svg) \ No newline at end of file diff --git a/docs/src/makielayout/button.md b/docs/src/makielayout/button.md index 0151bdcc9..399234d73 100644 --- a/docs/src/makielayout/button.md +++ b/docs/src/makielayout/button.md @@ -22,8 +22,4 @@ for button in buttons end fig - -save("example_lbutton.svg", fig); nothing # hide ``` - -![example lbutton](example_lbutton.svg) \ No newline at end of file diff --git a/docs/src/makielayout/colorbar.md b/docs/src/makielayout/colorbar.md index efedcdb2c..20fb2b59f 100644 --- a/docs/src/makielayout/colorbar.md +++ b/docs/src/makielayout/colorbar.md @@ -36,12 +36,8 @@ Colorbar(fig[4, 1], height = 25, limits = (-1, 1), colormap = :heat, highclip = :cyan, lowclip = :red) fig - -save("example_colorbar.svg", fig); nothing # hide ``` -![example colorbar](example_colorbar.svg) - You can also automatically choose colormap and limits for certain plot objects by passing them as the second argument. ```@example @@ -69,8 +65,5 @@ ax, hm = contourf(fig[2, 2][1, 1], xs, ys, zs, Colorbar(fig[2, 2][1, 2], hm, width = 20, ticks = -1:0.25:1) fig -save("example_colorbar_2.svg", fig); nothing # hide ``` -![example colorbar 2](example_colorbar_2.svg) - diff --git a/docs/src/makielayout/gridlayout.md b/docs/src/makielayout/gridlayout.md index 8b38d6a70..3970ccfea 100755 --- a/docs/src/makielayout/gridlayout.md +++ b/docs/src/makielayout/gridlayout.md @@ -26,12 +26,8 @@ colsize!(layout, 1, Fixed(400)) # colsize!(layout, 1, 400) would also work scene -save("example_fixed_size.svg", scene); nothing # hide ``` -![fixed size](example_fixed_size.svg) - - ### Relative `Relative(fraction)` is used to set a column or row to a size that is a certain fraction of the available width or height. @@ -50,11 +46,8 @@ layout[1, 3] = Colorbar(scene, width = 30) colsize!(layout, 1, Relative(2/3)) scene -save("example_relative_size.svg", scene); nothing # hide ``` -![relative size](example_relative_size.svg) - ### Auto @@ -92,11 +85,8 @@ colsize!(layout, 2, Auto(1)) # equivalent to Auto(true, 1) colsize!(layout, 3, Auto(2)) # equivalent to Auto(true, 2) scene -save("example_auto_size.svg", scene); nothing # hide ``` -![auto size](example_auto_size.svg) - ### Aspect @@ -120,11 +110,8 @@ rowsize!(layout, 2, Relative(2/3)) colsize!(layout, 1, Aspect(1, 1)) scene -save("example_aspect_size.svg", scene); nothing # hide ``` -![aspect size](example_aspect_size.svg) - !!! note Keep in mind that if you set too many constraints on row and column sizes, a GridLayout can easily be too big or too small. It's good to have variable-width elements to fill the remaining space if you use an element with fixed size or fixed aspect ratio. @@ -152,11 +139,9 @@ subgl_right[1:3, 1] = [Axis(scene) for i in 1:3] layout[1, 1] = subgl_left layout[1, 2] = subgl_right -save("example_nested_grids.svg", scene); nothing # hide +scene ``` -![example nested grids](example_nested_grids.svg) - ## Alignment Here you can see the difference between the align modes Outside with and without @@ -185,10 +170,9 @@ subgl_3[1, 1] = Axis(scene, title="Outside(50)") layout[1:3, 2] = [Box(scene, color = :transparent, strokecolor = :red) for i in 1:3] -save("example_grid_alignment.svg", scene); nothing # hide +scene ``` -![example grid alignment](example_grid_alignment.svg) ## Spanned Placement @@ -207,11 +191,9 @@ layout[:, 3] = Axis(scene, title="[:, 3]") layout[1:3, end] = Axis(scene, title="[1:3, end]") layout[end, end] = Axis(scene, title="[end, end]") -save("example_spanned_grid_content.svg", scene); nothing # hide +scene ``` -![spanned grid content](example_spanned_grid_content.svg) - ## Adding rows and columns by indexing If you index outside of the current range of a grid layout, you do not get an @@ -237,11 +219,9 @@ layout[2:end-1, 0] = Label(scene, text="Left Text", textsize=50, layout[2:end-1, end+1] = Label(scene, text="Right Text", textsize=50, rotation=-pi/2) -save("example_indexing_outside_grid.svg", scene); nothing # hide +scene ``` -![indexing outside grid](example_indexing_outside_grid.svg) - ## Trimming empty rows and columns @@ -259,11 +239,8 @@ ax1 = layout[1, 1] = Axis(scene, title = "Axis 1") ax2 = layout[1, 2] = Axis(scene, title = "Axis 2") scene -save("example_trimming_1.svg", scene); nothing # hide ``` -![trimming 1](example_trimming_1.svg) - Now we decide we'd like the second axis better if it was below the first one. We move it two the new cell, and the old unused column is left blank. @@ -271,22 +248,16 @@ We move it two the new cell, and the old unused column is left blank. layout[2, 1] = ax2 scene -save("example_trimming_2.svg", scene); nothing # hide ``` -![trimming 2](example_trimming_2.svg) - We can get rid of the unused space with `trim!`: ```@example trimming trim!(layout) scene -save("example_trimming_3.svg", scene); nothing # hide ``` -![trimming 3](example_trimming_3.svg) - ## Tweaking space between rows and columns @@ -308,22 +279,16 @@ hidedecorations!.(axs, grid=false) colgap!(fig.layout, 1, Relative(0.15)) fig -save("example_spacing_1.svg", fig); nothing # hide ``` -![spacing 1](example_spacing_1.svg) - All spaces can be changed at once by omitting the index of the gap to resize. ```@example spacing rowgap!(fig.layout, 50) fig -save("example_spacing_2.svg", fig); nothing # hide ``` -![spacing 2](example_spacing_2.svg) - ```@eval using GLMakie diff --git a/docs/src/makielayout/label.md b/docs/src/makielayout/label.md index 6a72ff22b..cd5f5d163 100644 --- a/docs/src/makielayout/label.md +++ b/docs/src/makielayout/label.md @@ -19,8 +19,5 @@ supertitle = Label(fig[0, :], "Six plots", textsize = 30) sideinfo = Label(fig[2:3, 0], "This text is vertical", rotation = pi/2) -save("example_ltext.svg", fig); nothing # hide +fig ``` - -![example ltext](example_ltext.svg) - diff --git a/docs/src/makielayout/layoutables.md b/docs/src/makielayout/layoutables.md index 5dd6f6317..2253c8ca4 100755 --- a/docs/src/makielayout/layoutables.md +++ b/docs/src/makielayout/layoutables.md @@ -27,11 +27,8 @@ AbstractPlotting.inline!(true) # hide f = Figure(resolution = (800, 600)) ax = Axis(f[1, 1]) f -save("layoutables_figure.svg", f); nothing # hide ``` -![layoutables_figure](layoutables_figure.svg) - ## Adding to a Scene And here's how you can add the same Layoutable to a Scene, which is the primitive object underlying a Figure. @@ -46,11 +43,8 @@ AbstractPlotting.inline!(true) # hide scene, layout = layoutscene(resolution = (800, 600)) ax = layout[1, 1] = Axis(scene) scene -save("layoutables_scene.svg", scene); nothing # hide ``` -![layoutables_scene](layoutables_scene.svg) - ## Specifying a boundingbox directly Sometimes you just want to place a Layoutable in a specific location, without it being controlled by a dynamic layout. @@ -69,11 +63,8 @@ f = Figure(resolution = (800, 600)) Axis(f, bbox = BBox(100, 300, 100, 500), title = "Axis 1") Axis(f, bbox = BBox(400, 700, 200, 400), title = "Axis 2") f -save("layoutables_manual_bbox.svg", f); nothing # hide ``` -![layoutables_manual_bbox](layoutables_manual_bbox.svg) - ## Deleting Layoutables To remove layoutables from their layout and the figure or scene, use `delete!(layoutable)`. diff --git a/docs/src/makielayout/legend.md b/docs/src/makielayout/legend.md index faae268f5..561ed8b05 100755 --- a/docs/src/makielayout/legend.md +++ b/docs/src/makielayout/legend.md @@ -27,12 +27,9 @@ sca = scatter!(ax, xs, ys, color = :red, markersize = 15) leg = Legend(scene, [lin, sca, [lin, sca]], ["a line", "some dots", "both together"]) layout[1, 2] = leg -save("example_legend.svg", scene); nothing # hide +scene ``` -![example legend](example_legend.svg) - - ## Creating A Legend From An Axis You can also create a Legend by passing it an axis object, like `Axis`, `LScene` or `Scene`. @@ -51,11 +48,9 @@ lines!(0..15, x -> -cos(x), label = "-cos", color = :green) f[1, 2] = Legend(f, ax, "Trig Functions", framevisible = false) -save("example_legend_from_axis.svg", f); nothing # hide +f ``` -![example legend from axis](example_legend_from_axis.svg) - ## Multi-Bank Legend @@ -75,13 +70,9 @@ lins = [lines!(ax, xs, sin.(xs .+ 3v), color = RGBf0(v, 0, 1-v)) for v in 0:0.1: leg = Legend(scene, lins, string.(1:length(lins)), nbanks = 3) layout[1, 2] = leg - -save("example_legend_ncols.svg", scene); nothing # hide +scene ``` -![example legend ncols](example_legend_ncols.svg) - - ## Legend Inside An Axis @@ -110,11 +101,9 @@ axislegend("Titled Legend", position = :lb) axislegend(ax, [sc1, sc2], ["One", "Two"], "Selected Dots", position = :rb, orientation = :horizontal) - -save("example_axislegend.svg", f); nothing # hide +f ``` -![example axislegend](example_axislegend.svg) Alternatively, you can simply add a Legend to the same layout slot that an axis lives in. As long as the axis is bigger than the legend you can @@ -150,11 +139,9 @@ for leg in legends layout[1, 1] = leg end -save("example_legend_alignment.svg", scene); nothing # hide +scene ``` -![example legend alignment](example_legend_alignment.svg) - ## Creating Legend Entries Manually @@ -202,11 +189,9 @@ leg = layout[1, 2] = Legend(scene, ["Line & Marker", "Poly & Line", "Line", "Marker", "Poly"], patchsize = (35, 35)) -save("example_legend_entries.svg", scene); nothing # hide +scene ``` -![example legend entries](example_legend_entries.svg) - ## Horizontal Legend @@ -237,12 +222,9 @@ leg_horizontal = Legend(scene, [lin, sca, lin], ["a line", "some dots", "line ag orientation = :horizontal, tellwidth = false, tellheight = true) layout[2, 1] = leg_horizontal - -save("example_legend_horizontal.svg", scene); nothing # hide +scene ``` -![example legend horizontal](example_legend_horizontal.svg) - ## Multi-Group Legends @@ -295,12 +277,8 @@ legends[5].nbanks = 2 legends[6].nbanks = 2 scene - -save("example_multilegend.svg", scene); nothing # hide ``` -![example multilegend](example_multilegend.svg) - ```@eval using GLMakie GLMakie.activate!() diff --git a/docs/src/makielayout/menu.md b/docs/src/makielayout/menu.md index 7d5c3b046..ff8f12363 100644 --- a/docs/src/makielayout/menu.md +++ b/docs/src/makielayout/menu.md @@ -51,7 +51,5 @@ end menu2.is_open = true -save("example_lmenu.svg", fig); nothing # hide +fig ``` - -![example lmenu](example_lmenu.svg) \ No newline at end of file diff --git a/docs/src/makielayout/slider.md b/docs/src/makielayout/slider.md index bcfa3ecab..d21a16395 100644 --- a/docs/src/makielayout/slider.md +++ b/docs/src/makielayout/slider.md @@ -22,11 +22,9 @@ sl3 = Slider(fig[4, 1], range = 0:0.01:10, startvalue = 7) sl4 = Slider(fig[:, 2], range = 0:0.01:10, horizontal = false, tellwidth = true, height = nothing, width = Auto()) -save("example_lslider.svg", fig); nothing # hide +fig ``` -![example lslider](example_lslider.svg) - To create a horizontal layout containing a label, a slider, and a value label, use the convenience function [`AbstractPlotting.MakieLayout.labelslider!`](@ref), or, if you need multiple aligned rows of sliders, use [`AbstractPlotting.MakieLayout.labelslidergrid!`](@ref). ```@example @@ -50,11 +48,9 @@ set_close_to!(lsgrid.sliders[1], 230.3) set_close_to!(lsgrid.sliders[2], 628.4) set_close_to!(lsgrid.sliders[3], 15.9) -save("example_labelslidergrid.svg", fig); nothing # hide +fig ``` -![example labelslidergrid](example_labelslidergrid.svg) - If you want to programmatically move the slider, use the function [`AbstractPlotting.MakieLayout.set_close_to!`](@ref). Don't manipulate the `value` attribute directly, as there is no guarantee that this value exists in the range underlying the slider, and the slider's displayed value would diff --git a/docs/src/makielayout/toggle.md b/docs/src/makielayout/toggle.md index a18e8817c..99389d163 100644 --- a/docs/src/makielayout/toggle.md +++ b/docs/src/makielayout/toggle.md @@ -21,7 +21,5 @@ labels = [Label(fig, lift(x -> x ? "active" : "inactive", t.active)) fig[1, 2] = grid!(hcat(toggles, labels), tellheight = false) -save("example_ltoggle.svg", fig); nothing # hide +fig ``` - -![example ltoggle](example_ltoggle.svg) \ No newline at end of file diff --git a/docs/src/makielayout/tutorial.md b/docs/src/makielayout/tutorial.md index 8dcd64b0b..bcf47e6ff 100755 --- a/docs/src/makielayout/tutorial.md +++ b/docs/src/makielayout/tutorial.md @@ -8,7 +8,7 @@ CairoMakie.activate!() In this tutorial, we will see some of the capabilities of layouts in Makie while building a complex figure step by step. This is the final result we will create: -![step_22](step_22.svg) +![layout_tutorial_final](layout_tutorial_final.svg) All right, let's get started! @@ -46,11 +46,8 @@ noto_sans_bold = "../assets/NotoSans-Bold.ttf" fig = Figure(resolution = (1200, 700), backgroundcolor = RGBf0(0.98, 0.98, 0.98), font = noto_sans) fig -save("step_001.svg", fig) # hide -nothing # hide ``` -![step_001](step_001.svg) ## First axis @@ -68,11 +65,8 @@ like they could result from an experimental trial. ax1 = fig[1, 1] = Axis(fig, title = "Pre Treatment") fig -save("step_002.svg", fig) # hide -nothing # hide ``` -![step_002](step_002.svg) ## Plotting into an axis @@ -87,11 +81,8 @@ scat1 = scatter!(ax1, data1, color = (:red, 0.3), markersize = 15px, marker = '■') fig -save("step_003.svg", fig) # hide -nothing # hide ``` -![step_003](step_003.svg) ## Multiple axes @@ -118,11 +109,8 @@ ax2, line2 = lines(fig[1, 2], 7..17, x -> -x + 26, axis = (title = "Post Treatment",)) fig -save("step_004.svg", fig) # hide -nothing # hide ``` -![step_004](step_004.svg) As you can see, the first axis has shrunk to the left to make space for the new axis on the right. We can take another look at the `layout` to see how it has @@ -143,11 +131,8 @@ scat2 = scatter!(data2, color = (:blue, 0.3), markersize = 15px, marker = '▲') fig -save("step_005.svg", fig) # hide -nothing # hide ``` -![step_005](step_005.svg) ## Linking axes @@ -160,11 +145,8 @@ synchronized. The function `linkaxes!` links both x and y, `linkxaxes!` links on linkaxes!(ax1, ax2) fig -save("step_006.svg", fig) # hide -nothing # hide ``` -![step_006](step_006.svg) This looks good, but now both y-axes are the same, so we can hide the right one to make the plot less cluttered. We keep the grid lines, though. You can see that @@ -174,11 +156,8 @@ now that the y-axis is gone, the two Axes grow to fill the gap. hideydecorations!(ax2, grid = false) fig -save("step_007.svg", fig) # hide -nothing # hide ``` -![step_007](step_007.svg) Even though our plots are entirely made up, we should follow best practice and label the axes. We can do this with the `xlabel` and `ylabel` attributes of the `Axis`. @@ -189,11 +168,8 @@ ax2.xlabel = "Weight [kg]" ax1.ylabel = "Maximum Velocity [m/sec]" fig -save("step_007_2.svg", fig) # hide -nothing # hide ``` -![step_007 2](step_007_2.svg) ## Adding a legend @@ -209,11 +185,8 @@ leg = fig[1, end+1] = Legend(fig, ["f(x) = x", "Data", "f(x) = -x + 26", "Data"]) fig -save("step_008.svg", fig) # hide -nothing # hide ``` -![step_008](step_008.svg) You can see one nice feature of Makie here, which is that the legend takes much less horizontal space than the two axes. In fact, it takes exactly the space @@ -233,11 +206,8 @@ We want it in the second row, and spanning the first two columns. fig[2, 1:2] = leg fig -save("step_009.svg", fig) # hide -nothing # hide ``` -![step_009](step_009.svg) ## Fixing spacing issues @@ -254,11 +224,8 @@ We can remove empty cells in a layout by calling `trim!` on it: trim!(fig.layout) fig -save("step_010.svg", fig) # hide -nothing # hide ``` -![step_010](step_010.svg) This is much better already! But the legend still takes too much space vertically. The reason for that is the default `tellheight` setting of the legend. It's set to @@ -272,11 +239,8 @@ this behavior. So we set the `tellheight` attribute to `true`. leg.tellheight = true fig -save("step_011.svg", fig) # hide -nothing # hide ``` -![step_011](step_011.svg) Now the legend's row is shrunk to fit. One thing that we can do to improve the use of space is to change the legend's orientation to `:horizontal`. @@ -285,11 +249,8 @@ use of space is to change the legend's orientation to `:horizontal`. leg.orientation = :horizontal fig -save("step_012.svg", fig) # hide -nothing # hide ``` -![step_012](step_012.svg) ## Nested layouts @@ -305,11 +266,8 @@ hm_axes = fig[1:2, 3] = [Axis(fig, title = t) for t in ["Cell Assembly Pre", "Ce heatmaps = [heatmap!(ax, i .+ rand(20, 20)) for (i, ax) in enumerate(hm_axes)] fig -save("step_013.svg", fig) # hide -nothing # hide ``` -![step_013](step_013.svg) This looks weird, the two axes do not have the same height. Rather, the lower one has the height of the legend in the same row. What can we do to remedy this @@ -339,11 +297,8 @@ fig[1:2, 3] = hm_sublayout hm_sublayout[:v] = hm_axes fig -save("step_014.svg", fig) # hide -nothing # hide ``` -![step_014](step_014.svg) We don't care about the axis decorations, as it's often the case with image plots. The function `hidedecorations!` hides both x and y decorations at once. @@ -353,11 +308,8 @@ The function `hidedecorations!` hides both x and y decorations at once. hidedecorations!.(hm_axes) fig -save("step_015.svg", fig) # hide -nothing # hide ``` -![step_015](step_015.svg) ## Adding a colorbar @@ -383,11 +335,8 @@ end cbar = hm_sublayout[:, 2] = Colorbar(fig, heatmaps[1], label = "Activity [spikes/sec]") fig -save("step_016.svg", fig) # hide -nothing # hide ``` -![step_016](step_016.svg) 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. @@ -396,11 +345,8 @@ sublayout. Let's give it a fixed width of 30 units. cbar.width = 30 fig -save("step_017.svg", fig) # hide -nothing # hide ``` -![step_017](step_017.svg) 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. @@ -415,11 +361,8 @@ If you only specify a number like `30`, it is interpreted as `Fixed(30)`. cbar.height = Relative(2/3) fig -save("step_18.svg", fig) # hide -nothing # hide ``` -![step_18](step_18.svg) We don't really like the automatically chosen tick values here. Sometimes, the automatic algorithms just don't choose the values we want, so let's change them. @@ -429,11 +372,8 @@ We can set the `ticks` attribute to any iterable of numbers that we want. cbar.ticks = 1:0.5:3 fig -save("step_18b.svg", fig) # hide -nothing # hide ``` -![step_18b](step_18b.svg) ## Adding a title @@ -456,11 +396,8 @@ supertitle = fig[0, :] = Label(fig, "Complex Figures with Makie", textsize = 30, font = noto_sans_bold, color = (:black, 0.25)) fig -save("step_19.svg", fig) # hide -nothing # hide ``` -![step_19](step_19.svg) ## Subplot labels @@ -497,11 +434,8 @@ label_b = fig[2, 3, TopLeft()] = Label(fig, "B", textsize = 35, font = noto_sans_bold, halign = :right) fig -save("step_20.svg", fig) # hide -nothing # hide ``` -![step_20](step_20.svg) That looks good! You can see that the letters, larger than the axis titles, have increased the gap between the title and the axes to fit them. In most other @@ -516,11 +450,8 @@ label_a.padding = (0, 6, 16, 0) label_b.padding = (0, 6, 16, 0) fig -save("step_21.svg", fig) # hide -nothing # hide ``` -![step_21](step_21.svg) ## Tweaking aspect ratios @@ -542,12 +473,8 @@ because the left two axes will grow to fill the remaining space. colsize!(hm_sublayout, 1, Aspect(1, 1)) fig -save("step_22.svg", fig) # hide -nothing # hide ``` -![step_22](step_22.svg) - And there we have it! Hopefully this tutorial has given you an overview how to approach the creation of a complex figure in Makie. Check the rest of the documentation for more details and other dynamic parts like sliders and buttons! diff --git a/docs/src/plotting_functions/band.md b/docs/src/plotting_functions/band.md index 3279e19bc..b767024d1 100644 --- a/docs/src/plotting_functions/band.md +++ b/docs/src/plotting_functions/band.md @@ -22,7 +22,4 @@ band!(xs, ys_low, ys_high) band!(xs, ys_low .- 1, ys_high .-1, color = :red) f -save("example_band.svg", f); nothing # hide ``` - -![example band](example_band.svg) diff --git a/docs/src/plotting_functions/barplot.md b/docs/src/plotting_functions/barplot.md index ada502740..a93827b5a 100644 --- a/docs/src/plotting_functions/barplot.md +++ b/docs/src/plotting_functions/barplot.md @@ -21,9 +21,4 @@ barplot!(xs, ys, color = :red, strokecolor = :black, strokewidth = 1) barplot!(xs, ys .- 1, fillto = -1, color = xs, strokecolor = :black, strokewidth = 1) f -save("example_barplot.svg", f); nothing # hide ``` - -![example barplot](example_barplot.svg) - - diff --git a/docs/src/plotting_functions/contour.md b/docs/src/plotting_functions/contour.md index 0d5b6ab44..d4ce8314b 100644 --- a/docs/src/plotting_functions/contour.md +++ b/docs/src/plotting_functions/contour.md @@ -21,8 +21,4 @@ zs = [cos(x) * sin(y) for x in xs, y in ys] contour!(xs, ys, zs) f -save("example_contour.svg", f); nothing # hide ``` - -![example contour](example_contour.svg) - diff --git a/docs/src/plotting_functions/contourf.md b/docs/src/plotting_functions/contourf.md index 530cad948..143486206 100644 --- a/docs/src/plotting_functions/contourf.md +++ b/docs/src/plotting_functions/contourf.md @@ -21,11 +21,8 @@ co = contourf!(xs, ys, zs, levels = 10) Colorbar(f[1, 2], co, width = 20) f -save("example_contourf_1.svg", f); nothing # hide ``` -![example_contourf_1](example_contourf_1.svg) - ```@example using CairoMakie @@ -45,11 +42,8 @@ co = contourf!(xs, ys, zs, levels = -0.75:0.25:0.5, Colorbar(f[1, 2], co, width = 20) f -save("example_contourf_2.svg", f); nothing # hide ``` -![example_contourf_2](example_contourf_2.svg) - ```@example using CairoMakie @@ -70,8 +64,5 @@ co = contourf!(xs, ys, zs, Colorbar(f[1, 2], co, width = 20) f -save("example_contourf_3.svg", f); nothing # hide ``` -![example_contourf_3](example_contourf_3.svg) - diff --git a/docs/src/plotting_functions/density.md b/docs/src/plotting_functions/density.md index 9551705cd..1cd988fce 100644 --- a/docs/src/plotting_functions/density.md +++ b/docs/src/plotting_functions/density.md @@ -17,13 +17,8 @@ Axis(f[1, 1]) density!(randn(200)) f -save("example_density_1.svg", f); nothing # hide ``` -![example_density_1](example_density_1.svg) - - - ```@example using CairoMakie @@ -36,13 +31,8 @@ Axis(f[1, 1]) density!(randn(200), direction = :y, npoints = 10) f -save("example_density_2_.svg", f); nothing # hide ``` -![example_density_2_](example_density_2_.svg) - - - ```@example using CairoMakie @@ -56,13 +46,8 @@ density!(randn(200), color = (:red, 0.3), strokecolor = :red, strokewidth = 3, strokearound = true) f -save("example_density_3.svg", f); nothing # hide ``` -![example_density_3](example_density_3.svg) - - - ```@example using CairoMakie @@ -80,8 +65,4 @@ for (i, vector) in enumerate(vectors) end f -save("example_density_4_.svg", f); nothing # hide ``` - -![example_density_4_](example_density_4_.svg) - diff --git a/docs/src/plotting_functions/errorbars.md b/docs/src/plotting_functions/errorbars.md index 21676599c..d7584c11b 100644 --- a/docs/src/plotting_functions/errorbars.md +++ b/docs/src/plotting_functions/errorbars.md @@ -26,13 +26,9 @@ errorbars!(xs, ys, higherrors, color = :red) # same low and high error scatter!(xs, ys, markersize = 3, color = :black) f -save("example_errorbars_1.svg", f); nothing # hide ``` - -![example_errorbars_1](example_errorbars_1.svg) - ```@example using CairoMakie CairoMakie.activate!() # hide @@ -53,12 +49,8 @@ errorbars!(xs, ys, lowerrors, higherrors, color = LinRange(0, 1, length(xs))) scatter!(xs, ys, markersize = 3, color = :black) f -save("example_errorbars_2_.svg", f); nothing # hide ``` -![example_errorbars_2_](example_errorbars_2_.svg) - - ```@example using CairoMakie @@ -80,8 +72,4 @@ errorbars!(xs, ys, lowerrors, higherrors, whiskerwidth = 3, direction = :x) scatter!(xs, ys, markersize = 3, color = :black) f -save("example_errorbars_3_.svg", f); nothing # hide ``` - -![example_errorbars_3_](example_errorbars_3_.svg) - diff --git a/docs/src/plotting_functions/heatmap.md b/docs/src/plotting_functions/heatmap.md index aedf36645..a133f3ea1 100644 --- a/docs/src/plotting_functions/heatmap.md +++ b/docs/src/plotting_functions/heatmap.md @@ -15,16 +15,11 @@ AbstractPlotting.inline!(true) # hide f = Figure(resolution = (800, 600)) Axis(f[1, 1]) -xs = LinRange(0, 10, 100) -ys = LinRange(0, 15, 100) +xs = LinRange(0, 10, 25) +ys = LinRange(0, 15, 25) zs = [cos(x) * sin(y) for x in xs, y in ys] heatmap!(xs, ys, zs) f -save("example_heatmap_1.svg", f); nothing # hide ``` - -![example_heatmap_1](example_heatmap_1.svg) - - diff --git a/docs/src/plotting_functions/image.md b/docs/src/plotting_functions/image.md index c0e90cc46..d8353c804 100644 --- a/docs/src/plotting_functions/image.md +++ b/docs/src/plotting_functions/image.md @@ -20,9 +20,4 @@ Axis(f[1, 1], aspect = DataAspect()) image!(img) f -save("example_image_1.svg", f); nothing # hide ``` - -![example_image_1](example_image_1.svg) - - diff --git a/docs/src/plotting_functions/lines.md b/docs/src/plotting_functions/lines.md index c43344548..3f9afbf1a 100644 --- a/docs/src/plotting_functions/lines.md +++ b/docs/src/plotting_functions/lines.md @@ -23,7 +23,4 @@ lines!(xs, ys .- 2, linewidth = 5, color = ys) lines!(xs, ys .- 3, linestyle = :dash) f -save("example_lines_1.svg", f); nothing # hide ``` - -![example_lines_1](example_lines_1.svg) diff --git a/docs/src/plotting_functions/linesegments.md b/docs/src/plotting_functions/linesegments.md index 7ccf0b157..5fd64a239 100644 --- a/docs/src/plotting_functions/linesegments.md +++ b/docs/src/plotting_functions/linesegments.md @@ -22,9 +22,4 @@ linesegments!(xs, ys .- 1, linewidth = 5) linesegments!(xs, ys .- 2, linewidth = 5, color = LinRange(1, 5, length(xs))) f -save("example_linesegments.svg", f); nothing # hide ``` - -![example linesegments](example_linesegments.svg) - - diff --git a/docs/src/plotting_functions/poly.md b/docs/src/plotting_functions/poly.md index 73161f23b..d48efa521 100644 --- a/docs/src/plotting_functions/poly.md +++ b/docs/src/plotting_functions/poly.md @@ -18,12 +18,8 @@ Axis(f[1, 1]) poly!(Point2f0[(0, 0), (2, 0), (3, 1), (1, 1)], color = :red, strokecolor = :black, strokewidth = 1) f -save("example_poly_1.svg", f); nothing # hide ``` -![example_poly_1](example_poly_1.svg) - - ```@example using CairoMakie @@ -43,10 +39,8 @@ p = Polygon( poly!(p, color = :blue) f -save("example_poly_2_.svg", f); nothing # hide ``` -![example_poly_2_](example_poly_2_.svg) ```@example using CairoMakie @@ -65,11 +59,8 @@ poly!( ) f -save("example_poly_3.svg", f); nothing # hide ``` -![example_poly_3](example_poly_3.svg) - ```@example @@ -85,10 +76,8 @@ Axis(f[1, 1], aspect = DataAspect()) poly!(Circle(Point2f0(0, 0), 15f0), color = :pink) f -save("example_poly_4.svg", f); nothing # hide ``` -![example_poly_4](example_poly_4.svg) ```@example using CairoMakie @@ -107,7 +96,4 @@ poly!(ps, color = rand(RGBf0, length(ps)), axis = (backgroundcolor = :gray15,)) f -save("example_poly_5.svg", f); nothing # hide ``` - -![example_poly_5](example_poly_5.svg) diff --git a/docs/src/plotting_functions/rangebars.md b/docs/src/plotting_functions/rangebars.md index 20a50865d..ea24eb4f4 100644 --- a/docs/src/plotting_functions/rangebars.md +++ b/docs/src/plotting_functions/rangebars.md @@ -21,12 +21,8 @@ highs = LinRange(0.1, 0.4, length(vals)) rangebars!(vals, lows, highs, color = :red) f -save("example_rangebars_1.svg", f); nothing # hide ``` -![example_rangebars_1](example_rangebars_1.svg) - - ```@example using CairoMakie @@ -44,8 +40,5 @@ rangebars!(vals, lows, highs, color = LinRange(0, 1, length(vals)), whiskerwidth = 3, direction = :x) f -save("example_rangebars_2.svg", f); nothing # hide ``` -![example_rangebars_2](example_rangebars_2.svg) - diff --git a/docs/src/plotting_functions/scatter.md b/docs/src/plotting_functions/scatter.md index c08b4bbe1..6483e750a 100644 --- a/docs/src/plotting_functions/scatter.md +++ b/docs/src/plotting_functions/scatter.md @@ -23,8 +23,4 @@ scatter!(xs, ys .- 2, markersize = LinRange(5, 30, 20)) scatter!(xs, ys .- 3, marker = 'a':'t', strokewidth = 0, color = :black) f -save("example_scatter_1.svg", f); nothing # hide ``` - -![example_scatter_1](example_scatter_1.svg) - diff --git a/docs/src/plotting_functions/scatterlines.md b/docs/src/plotting_functions/scatterlines.md index 15834d7aa..869903c36 100644 --- a/docs/src/plotting_functions/scatterlines.md +++ b/docs/src/plotting_functions/scatterlines.md @@ -24,8 +24,4 @@ scatterlines!(xs, ys .- 3, marker = :cross, strokewidth = 0, strokecolor = :red, markercolor = :orange) f -save("example_scatterlines_1.svg", f); nothing # hide ``` - -![example_scatterlines_1](example_scatterlines_1.svg) - diff --git a/docs/src/plotting_functions/stem.md b/docs/src/plotting_functions/stem.md index 7f313ec54..6fc9769fc 100644 --- a/docs/src/plotting_functions/stem.md +++ b/docs/src/plotting_functions/stem.md @@ -19,12 +19,8 @@ xs = LinRange(0, 4pi, 30) stem!(xs, sin.(xs)) f -save("example_stem_1.svg", f); nothing # hide ``` -![example stem_1](example_stem_1.svg) - - ```@example using CairoMakie @@ -43,12 +39,8 @@ stem!(xs, sin, trunklinestyle = :dash, stemlinestyle = :dashdot) f -save("example_stem_2.svg", f); nothing # hide ``` -![example stem_2](example_stem_2.svg) - - ```@example using CairoMakie @@ -66,12 +58,8 @@ stem!(xs, sin.(xs), trunkcolor = LinRange(0, 1, 30), trunkwidth = 5) f -save("example_stem_3.svg", f); nothing # hide ``` -![example stem_3](example_stem_3.svg) - - ```@example using GLMakie diff --git a/docs/src/recipes.md b/docs/src/recipes.md index 7cb0c8440..e6453bc42 100644 --- a/docs/src/recipes.md +++ b/docs/src/recipes.md @@ -263,11 +263,8 @@ stockchart(f[1, 1], timestamps, stockvalues) stockchart(f[2, 1], timestamps, stockvalues, downcolor = :purple, upcolor = :orange) f -save("example_stockchart.svg", f); nothing # hide ``` -![example stockchart](example_stockchart.svg) - As a last example, lets pretend our stock data is coming in dynamically, and we want to create an animation out of it. This is easy if we use observables as input arguments which we then update frame by frame: