I’m trying to make a histogram in Julia using hist
command from Makie
, as detailed here:
I’m using CairoMakie to make a heatmap in Julia 1.7.3
I’d like to add a single smiley face (or really any marker) in the very center of the heatmap, at say 50 x 50.
This seems like a super simple task, but I’ve been looking online and haven’t found anything. The most basic thing to do would seem to be use scatter, which I can make work if I have multiple points, but not if I only want to put one.
Can anyone point me in the right direction?
I would like to control the xlimits, i.e. force the x range to go from 0 to 5.
I can’t seem to find anywhere how to do this online, the closest I get is a discussion of xlim!
which does not seem to apply to my setting.
Can anyone point me in the right direction?
Howdy again, here’s a couple ways that come to mind based on the docs here :
using CairoMakie
fig = Figure()
limits = (-0.75, 0.75, nothing, nothing)
ax_left = Axis(fig[1, 1]; title="Original data")
ax_middle = Axis(fig[1, 2]; limits, title="Axis keyword")
ax_right = Axis(fig[1, 3]; title="xlims!")
x = randn(1000)
# Regular
hist!(ax_left, x)
# Zoomed with Axis setup above
hist!(ax_middle, x)
# Zoomed with xlims!
hist!(ax_right, x)
xlims!(-0.75, 0.75)
fig
Interestingly, trying to use a special keyword on an already existing axis fails:
hist!(ax_right, x; axis=(; limits))
# Error: setting axis for scene via plot attribute not supported anymore
but creating it all in one shot is still fine:
hist(x; axis=(; limits))
I think this may be related to this issue? Wrong error when trying to set axis elements in `hist!` call · Issue #2005 · JuliaPlots/Makie.jl · GitHub
jling
June 9, 2022, 12:08am
4
it sounds like they deprecated this usage
it makes sense that the one-shot version works, because in one-shot, you can’t have conflicting axis setting, where here if you !()
incompatible axis setting, what’s the overriding rules? merging? replace entirely with the last called axis
?
That’s a good point. I didn’t think about how the statefulness would come into play
jules
June 9, 2022, 6:13am
6
Yes that’s exactly the reason, you can only pass attributes when an Axis is created. I don’t know how it works in Plots.jl, do later calls merge with previous attributes and override ones that have been set twice?