Tufte/Offset/Despine Axes in Makie or other plot libraries

Hello,

I’m wondering if it is possible to make Tufted/Offset/Despined axes in pure Julia.

This is a basic example (this was generated in python using seaborn.despine. You can do the same in R and pgfplots):
test

I looked in the documentation for Makie and came up with nothing. I’m sure you can do this in PGFplotsX fairly simply by passing pgfplots or with PyPlot, but I was wondering if there was a way to do so in Makie since that seems to be the future direction that visualization is taking in Julia.

For completeness, here’s some simple code to produce the same figure in CairoMakie:

using CairoMakie
f = Figure()
ax = Axis(f[1,1],spinewidth = 1, xgridvisible = false,ygridvisible = false, xtickwidth = 1)
hidespines!(ax,:t,:r)
lineobject = lines!(ax, 0..10, sin, color = :red)

I think I implemented that a long time ago… It’s not documented though, so no wonder you couldn’t find it. Try passing these attributes to the axis:

"Controls if the x spine is limited to the furthest tick marks or not."
xtrimspine = true
"Controls if the y spine is limited to the furthest tick marks or not."
ytrimspine = true
1 Like

You need to do:

using CairoMakie
f = Figure()
ax = Axis(f[1,1], spinewidth = 1, xgridvisible = false, ygridvisible = false, xtickwidth = 1)
hidespines!(ax,:t,:r)
lineobject = lines!(ax, 0..10, sin, color = :red)
ax.xtrimspine=true
ax.ytrimspine=true
f 

Since otherwise, without anything plotted, the ticks are empty and trimspine will try to access the ticks

2 Likes