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

fix legend colorrange #3536

Closed
wants to merge 3 commits into from
Closed

fix legend colorrange #3536

wants to merge 3 commits into from

Conversation

t-bltg
Copy link
Collaborator

@t-bltg t-bltg commented Jan 7, 2024

Description

Fix #3532.

Type of change

Delete options that do not apply:

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist

  • Added an entry in NEWS.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.

@t-bltg
Copy link
Collaborator Author

t-bltg commented Jan 7, 2024

New reference images, adapted from OP's bug report:

using CairoMakie

main() = begin
  f = Figure()
  ax = Axis(f[1, 1])
  foreach(i -> lines!(ax, i:i+1; colorrange = (1, 4), colormap = :cividis, color = i, label = string(i)), 1:4)
  f[1, 2] = Legend(f, ax, "Legend")
  save("leg1.png", f)
  display(f)

  f = Figure()
  ax = Axis(f[1, 1])
  foreach(i -> lines!(ax, i:i+1; colorrange = (1, 4), colormap = :cividis, color = i, label = string(i)), 1:4)
  axislegend(ax)
  save("leg2.png", f)
  display(f)

  f = Figure()
  ax = Axis(f[1, 1])
  foreach(i -> scatter!(ax, i:i+1, i:i+1; colorrange = (1, 4), colormap = :cividis, color = i, label = string(i), marker = :hexagon), 1:4)
  axislegend(ax)
  save("leg3.png", f)
  display(f)

  f = Figure()
  ax = Axis(f[1, 1])
  foreach(i -> poly!(ax, Rect(i, i, 0.5, 0.25); colorrange = (1, 4), colormap = :cividis, color = i, label = string(i)), 1:4)
  axislegend(ax)
  save("leg4.png", f)
  display(f)

  return
end

main()

leg1
leg2
leg3
leg4

@t-bltg t-bltg removed the request for review from jkrumbiegel January 7, 2024 11:25
@t-bltg t-bltg marked this pull request as draft January 7, 2024 11:25
@t-bltg t-bltg marked this pull request as ready for review January 7, 2024 12:02
@jkrumbiegel
Copy link
Member

This doesn't copy the colormap I think, so it would break if your test didn't use the default. Could you add the same treatment (and tests) for marker and poly elements as well? Then everything would work the same way.

@t-bltg
Copy link
Collaborator Author

t-bltg commented Jan 7, 2024

This doesn't copy the colormap I think, so it would break if your test didn't use the default.

Good point, I will check that.

Could you add the same treatment (and tests) for marker and poly elements as well?

Will do.

@t-bltg
Copy link
Collaborator Author

t-bltg commented Jan 7, 2024

@jkrumbiegel , I've updated the examples in #3536 (comment), added reference tests, and fixed propagation of the colormap attribute.

Does that fix your requests ?

@jkrumbiegel
Copy link
Member

jkrumbiegel commented Feb 1, 2024

Thanks again for the PR, I've pushed another PR that does a slightly different variant of this over here #3587 but this helped me get that one done

@jkrumbiegel jkrumbiegel closed this Feb 1, 2024
@t-bltg t-bltg deleted the crange branch February 1, 2024 22:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Legend not working when using custom colorrange
2 participants