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 misaligned colors in colorbar? #4618

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

briochemc
Copy link
Contributor

@briochemc briochemc commented Nov 22, 2024

Description

Fixes #4121?

Currently the Colorbar built from a contourf may have misaligned colors. For a MWE see #4121 or

l = [1, 2, 5, 10, 20, 50]
x = 0:0.1:51
y = 0:0.1:51
z = [y for x in x, y in y]
fig, ax, plt = contourf(x, y, z; levels = l, extendhigh=:auto, extendlow=:auto)
cb = Colorbar(fig[1, 2], plt; tellheight = false)

which produces this misalignment (I edited the image in Preview to show the differences in colors):

test

The issue seems to be that the continuous_pixels (used to draw the heatmap for the colorbar) are not scaled properly. Simply adding the colorrange kwarg to that call fixes this issue for me, with properly matching colors:

Screenshot 2024-11-22 at 1 27 43 pm

However, I'm not if this breaks other things elsewhere, so hopefully someone can hold my hand to finish this PR?

Type of change

Delete options that do not apply:

  • Bug fix (non-breaking change which fixes an issue)

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.

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

Successfully merging this pull request may close these issues.

Some of the levels are missing from Colorbar
1 participant