Hello everyone,
I have a gui which involves a contour plot with log-log axes.
The goal is to be able to select some points from within the plot by clicking on in.
Everything works fine in the case of linear axes:
MRE for linear axes
using GLMakie
f = Figure()
ax = Axis(f[:,:],)
# make some data to plot
x = range(0.001, 1, 100)
y = x
N = 100
σ = 15.0
μ = N / 2
z = [exp(-((x - μ)^2 + (y - μ)^2) / (2 * σ^2)) for y in 1:N, x in 1:N]
contour!(ax,x,y,z)
point = select_point(f.content[1].scene, marker=:circle)
# Update selection Observable by pushing the selected point to it
on(point) do _
display(point)
end
but as soon as the axis get changed to log10:
MRE for log10 axes
using GLMakie
f = Figure()
ax = Axis(f[:,:], xscale = log10, yscale = log10)
# make some data to plot
x = logrange(0.001, 1, 100)
y = x
N = 100
σ = 15.0
μ = N / 2
z = [exp(-((x - μ)^2 + (y - μ)^2) / (2 * σ^2)) for y in 1:N, x in 1:N]
contour!(ax,x,y,z)
point = select_point(f.content[1].scene, marker=:circle)
# Update selection Observable by pushing the selected point to it
on(point) do _
display(point)
end
there are errors:
Error in callback:
DomainError with -0.594361:
log10 was called with a negative real argument but will only return a complex result if called with a complex argument. Try log10(Complex(x)).
It seems that the select_point
function returns log10.(point)
rather than point
, or something like that.
When I was working on this, about a year ago, I ended up using two sets of axes, one for displaying the actual log-scale values, and a linear one from 0 to 1 to selecting points from it.
This used to work, but it becomes a bit problematic now that I need to be able to zoom in and out, while keeping these axes synced.
Would there be any straightforward ways to deal with either of these issues?
That is, either select the points directly from the log-log axes without pesky errors;
or keep two axes with different values in sync.