Is there any way to draw lines between axes somehow?
Here's an example figure from https://doi.org/10.1016/j.epsl.2010.09.044 that illustrates my intended end-goal with the green lines.
2024-09-06-150524_region.png
Here's an attempt at the simplest reprex I could think of:
using GLMakie
# Create a figure with two axes
fig = Figure()
ax1 = Axis(fig[1, 1], title="Plot 1")
ax2 = Axis(fig[1, 2], title="Plot 2")
# Define points in both axes
point1 = Point2f(0.3, 0.6)
point2 = Point2f(0.7, 0.4)
# Scatter points on each axis
scatter!(ax1, point1)
scatter!(ax2, point2)
# Draw a line between the points across the axes
# ???
# lines!(ax1, [point1, point2], linewidth=2, color=:green)
# lines!(ax2, [point1, point2], linewidth=2, color=:green)
lines!(fig[1,1:2], [point1, point2]) # errors
Questions about Makie are best asked on discourse, where the Makie devs
can see them and help.
But it should be possible, as Makie gives a lot of control.
Here is a related post, that might help.
https://discourse.julialang.org/t/visual-connection-between-different-axes-in-makie-jl/116535/9
the line points are given in the data coordinates of two different axes.
The core is this function that returns the scene coordinates from the axis data coordinates
function posFig(ax, x, y)
o = ax.scene.viewport[].origin
return Makie.project(ax.scene, Point2f(x, y)) + o
end
Then the line drawing is done on the scene itself, rather than on any axis.
lines!(fig.scene, ...
Awesome, thanks for linking to that answer! I didn't find it when searching. I'll be sure to ask future Makie questions over on discourse.
japhir has marked this topic as resolved.
The only downside I'm seeing so far is that this doesn't work with GLMakie's interactive figures.
ederag suggested how to do this on Discourse! https://discourse.julialang.org/t/visual-connection-between-different-axes-in-makie-jl/116535/10
Last updated: Nov 06 2024 at 04:40 UTC