Hide Axis Spines and Decorations

Package input

using TopoPlots
using UnfoldMakie
using CairoMakie
using DataFrames

include("../../../example_data.jl")
data, pos = example_data("TopoPlots.jl")
(25600×7 DataFrame
   Row │ estimate      time     channel  coefname  topo_positions        se    ⋯
       │ Float64       Float64  Int64    String    Any                   Float ⋯
───────┼────────────────────────────────────────────────────────────────────────
     1 │  0.020321      -0.3          1  A         (0.493714, 0.544031)  0.122 ⋯
     2 │  0.017548      -0.298        1  A         (0.493714, 0.544031)  0.124
     3 │  0.0150747     -0.296        1  A         (0.493714, 0.544031)  0.124
     4 │  0.0127718     -0.294        1  A         (0.493714, 0.544031)  0.124
     5 │  0.0104138     -0.292        1  A         (0.493714, 0.544031)  0.122 ⋯
     6 │  0.00782599    -0.29         1  A         (0.493714, 0.544031)  0.119
     7 │  0.00500377    -0.288        1  A         (0.493714, 0.544031)  0.114
     8 │  0.00214393    -0.286        1  A         (0.493714, 0.544031)  0.105
   ⋮   │      ⋮           ⋮        ⋮        ⋮               ⋮                ⋮ ⋱
 25594 │  0.121127       0.486       64  A         (0.719221, 0.888091)  0.247 ⋯
 25595 │  0.119454       0.488       64  A         (0.719221, 0.888091)  0.247
 25596 │  0.11769        0.49        64  A         (0.719221, 0.888091)  0.250
 25597 │  0.116001       0.492       64  A         (0.719221, 0.888091)  0.256
 25598 │  0.114315       0.494       64  A         (0.719221, 0.888091)  0.261 ⋯
 25599 │  0.112385       0.496       64  A         (0.719221, 0.888091)  0.262
 25600 │  0.109979       0.498       64  A         (0.719221, 0.888091)  0.258
                                                2 columns and 25585 rows omitted, Point{2, Float32}[[0.49371386, 0.5440313], [0.5630452, 0.50400287], [0.5630452, 0.4239459], [0.49371386, 0.38391745], [0.4243825, 0.4239459], [0.4243825, 0.50400287], [0.5378472, 0.6178857], [0.61455333, 0.56901854], [0.6522695, 0.4862579], [0.6388263, 0.39630732]  …  [0.93907887, 0.6439135], [0.9450873, 0.29968786], [0.8333667, 0.12432156], [0.61803544, 1.9428903f-16], [0.3693923, 2.7755576f-17], [0.15406103, 0.12432156], [0.029739477, 0.3396528], [0.04834886, 0.6439135], [0.26820713, 0.88809085], [0.7192206, 0.88809085]])

This section discusses how users can efficiently hide axis spines and decorations in their plots.

While it's possible to hide these axis decorations by setting the axis settings with axis=(;...), Makie.Axis provides multiple variables for different aspects of the plot. This means that removing all decorations is only possible by setting many variables each time.

Makie does provide methods like hidespines! and hidedecorations!, but the user may not have easy access to the axis their plot is drawn in.

Instead, these functions can be called by setting variables with layout = (; hidespines = (), hidedecorations = ()):

Since these values reflect the input to the function, we can use an empty tuple to remove all decorations and spines, respectively

And using hidespines = (:r, :t) will remove the top and right borders.

f = Figure()
plot_butterfly!(
    f[1, 1],
    data;
    positions = pos,
    topomarkersize = 10,
    topoheigth = 0.4,
    topowidth = 0.4,
)
plot_butterfly!(
    f[2, 1],
    data;
    positions = pos,
    topomarkersize = 10,
    topoheigth = 0.4,
    topowidth = 0.4,
    layout = (; hidedecorations = (:label => true, :ticks => true, :ticklabels => true)),
)
for (label, layout) in zip(["with decorations", "without"], [f[1, 1], f[2, 1]])
    Label(
        layout[1, 1, TopLeft()],
        label,
        fontsize = 26,
        font = :bold,
        padding = (0, -250, 25, 0),
        halign = :left,
    )
end
f
Example block output

Since some plots hide features by default, the hiding can be reverted by setting the variables to nothing

data, positions = TopoPlots.example_data()
plot_topoplot(
    data[:, 340, 1];
    positions = positions,
    layout = (; hidespines = nothing, hidedecorations = nothing),
)
Example block output

For more information on the input of these functions refer to the Makie dokumentation on Axis.


This page was generated using Literate.jl.