Makie, make axes invisible?

I really enjoy the fastness of Makie! I think it can really become the next generation plotting tool for Julia.
Currently I am struggelling with the axis interface.
Is there any convenient possibility to make the axes of a plot invisible?

For 3DAxis I found

scene = Scene()
lines!(scene, sin.(0:0.1:2*pi))
axis = scene[Axis]
axis[:showaxis] = (false, false, false)

and for 2DAxis I found the property axis[:visible]
but neither the 2D nor the 3D versions work for me :frowning:

Currently I have the following workaround:

function axis_off(scene) 
    axis = scene[Axis]
    axis[:names][:axisnames] = ("","")
    axis[:grid][:linewidth] = (0, 0)
    axis[:ticks][:textsize] = (0, 0)
    scene
end

But I may be missing something …?
Thanks in advance for any help.

2 Likes

Just realised, that

lines(sin.(0:0.1:2*pi), show_axis = false)

works, I must have had a typo somewhere, when trying the first time.
I would still be interested in knowing whether I could switch axes plotting on/off after the plot has been made…

P.S.: a nice example for Valentine’s Day :wink:

h(x) = abs(x)^(2/3) +  sqrt(3.3-x^2) * cos(150*pi*x)
lines(h.(LinRange(-sqrt(3.3),sqrt(3.3),10000)), color = :red, show_axis=false)
2 Likes

If you are using the Axis workflow, the way to hide everything is

ax = Axis()  # customized as you see fit
hidedecorations!(ax)  # hides ticks, grid and lables
hidespines!(ax)  # hide the frame

as described in the documentation.

Since this post is the first result I got from google I figured it may be worth updating it.

4 Likes

To add to this, the reason is not that I like removing simple keywords, but that show_axis controlled whether the plot object Axis2D or 3D was added to the scene or not, which is a binary yes no thing. Now, with the Axis that is a complex container object for a scene, that logic doesn’t work anymore, as the axis doesn’t have a single on/off switch as it did before, it’s always there

2 Likes

What is the way to turn axes off in a LScene?

@mschauer, does this do it?

LScene(scenekw = (show_axis = false,))

3 Likes

What is the current way to do this?

1 Like

For hiding various axis and figure boarders, ticks and grids see Makie documentation for:

hidexdecorations!
hideydecorations!
hidedecorations!
hidespines!

2 Likes

By the way, would someone know how to only remove the grey background grid of a plot?
hidecorations gets rid of it but also removes all axis information.

Use the keyword arguments of hide[x,y]decorations!, see the link above.

I see, thanks! The following is lengthy but does the job.

  hidexdecorations!(ax; label = false, ticklabels = false, ticks = false, grid = true,
    minorgrid = false, minorticks = false)
  hideydecorations!(ax; label = false, ticklabels = false, ticks = false, grid = true,
    minorgrid = false, minorticks = false)

You can directly set xgridvisible = false etc. on the Axis

1 Like

Can we have a code snipped to copy and paste here?

I actually don’t know what exactly people is looking to do but:

julia> using CairoMakie

julia> fig, ax = scatter(rand(3), rand(3)); hidedecorations!(ax); hidespines!(ax); fig

1 Like