How to set axis ranges with density plot in CairoMakie?

264 views Asked by At

Is it possible to fix the range of x and y axis in a density plot with CairoMakie ?

For an example, I would like to fix the range of x axis from 10 to 100 and force the y axis to start from 0 (I want to remove the gap above the major x axis)

fig = CairoMakie.density(ages_obtention, color = (:blue, 0.3),
    strokecolor = :blue, strokewidth = 2, strokearound = true,
    )

enter image description here

1

There are 1 answers

0
August On

You can use xlims! and ylims!

fig = CairoMakie.density(ages_obtention, color = (:blue, 0.3),
    strokecolor = :blue, strokewidth = 2, strokearound = true,
)
xlims!(fig.axis, (10, 100))
ylims!(fig.axis, (0, nothing))

fig