Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

linkaxes! works only when changing the limits of the most recently created axis #4837

Open
3 tasks done
egavazzi opened this issue Mar 1, 2025 · 1 comment
Open
3 tasks done
Labels

Comments

@egavazzi
Copy link

egavazzi commented Mar 1, 2025

When linkaxes! (or its variants linkxaxes! and linkyaxes!) is used, changing the limits of the axis seems to work only if applied to the most recently created axis.

In this MWE, changing the limits of ax1 has no effect (tested with GLMakie and CairoMakie).

using GLMakie

x = 1:10
y = rand(10)
## Does not work
f = Figure()
ax1 = Axis(f[1, 1])
sc1 = scatter!(ax1, x, y)
ax2 = Axis(f[2, 1])
sc2 = scatter!(ax2, x, y)
linkaxes!(ax1, ax2)
xlims!(ax1, 4, 8)
display(f)

Image

Note: when executing the code line by line, xlims!(ax1, 4, 8) does update correctly all the axis, but then display(f) resets the limits.

If xlims! is applied to ax2 instead, everything works fine

## Does work
f = Figure()
ax1 = Axis(f[1, 1])
sc1 = scatter!(ax1, x, y)
ax2 = Axis(f[2, 1])
sc2 = scatter!(ax2, x, y)
linkaxes!(ax1, ax2)
xlims!(ax2, 4, 8)
display(f)

Image

Changing the order of ax1, ax2 in linkaxes! (i.e. trying linkaxes!(ax2, ax1) instead of linkaxes!(ax1, ax2)) does not change the results.

From my testing (including trying to link more than two axis), xlims!/ylims! seems to work only if applied to the last one that was created.

Same behavior is seen when setting the limits directly with the limits attribute when creating the axis.



  • what version of Makie are you running? (]st -m Makie)
    ➡ [ee78f7c6] Makie v0.22.2
  • can you reproduce the bug with a fresh environment ? (]activate --temp; add Makie)
  • What platform + GPU are you on?
    ➡ Linux, Nvidia RTX A2000
@egavazzi egavazzi added the bug label Mar 1, 2025
@egavazzi
Copy link
Author

egavazzi commented Mar 1, 2025

I also noticed something which I think is related (not sure if it should have its own issue). After linking some axis, if one resets the limits with ctrl + leftclick or reset_limits!(ax), the behavior is different depending on the axis:

  • the axis that had its limits explicitly set with xlims!/ylims! will reset to those values (and update the other axis limits)
  • the axis that had their limits changed through the linkaxes! will ignore the limits from xlims!/ylims! and reset to their original limits (and update the other axis limits)
using GLMakie

x = 1:10
y = rand(10)
## Does work
f = Figure()
ax1 = Axis(f[1, 1])
sc1 = scatter!(ax1, x, y)
ax2 = Axis(f[2, 1])
sc2 = scatter!(ax2, x, y)
linkaxes!(ax1, ax2)
xlims!(ax2, 4, 8)
display(f)

reset_limits!(ax1)

Additional fun! Saving the figure with save or executing display(f) will actually reset the limits of both axis to the ones set with xlims!, which is more the expected behavior.

So here is a screenshot instead

Image
➡ the limits are reset to the original ones of ax1, ignoring xlims!.

And here after using save

Image
➡ the limits are reset to the ones given with xlims!.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant