Skip to content

allow Legend to be created from multiple Axis #4984

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

TomRottier
Copy link
Contributor

@TomRottier TomRottier commented May 15, 2025

Description

Adds the ability to create a Legend from a vector of axes.

Modified from https://discourse.julialang.org/t/how-to-combine-the-legend-of-multiple-axes-on-same-figure-into-one-in-makie-jl/97299/3?u=tomrottier

using GLMakie

f = Figure()
ax1 = Axis(f[1,1])
ax2 = Axis(f[1,2])

ps = [0.1, 0.2, 0.3, 0.4]
xs = range(0, 5, 100)
f1(x, p) = p * x^2
f2(x, p) = p * sin(x)

for p in ps
    lines!(ax1, xs, f1.(xs, p), label=string(p))
    lines!(ax2, xs, f2.(xs, p), label=string(p))
end

scatter!(ax1, xs[1:5:end], f1.(xs[1:5:end], ps[1]), label=string(ps[1]), )

Legend(f[2,:], [ax1, ax2], orientation=:horizontal, merge=true, unique=false)

tmp

Type of change

  • New feature (non-breaking change which adds functionality)

Checklist

  • Added an entry in CHANGELOG.md (for new features and breaking changes)
  • Added or changed relevant sections in the documentation
  • Added unit tests for new algorithms, conversion methods, etc.
  • Added reference image tests for new plotting functions, recipes, visual options, etc.

@github-project-automation github-project-automation bot moved this to Work in progress in PR review May 15, 2025
@TomRottier TomRottier marked this pull request as ready for review May 15, 2025 21:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Work in progress
Development

Successfully merging this pull request may close these issues.

1 participant