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

Colorbar under histogram #2514

Closed
wants to merge 2 commits into from
Closed

Conversation

pllim
Copy link
Contributor

@pllim pllim commented Oct 16, 2023

Description

This pull request is to add a colorbar to build on #2498. Alas, it is not as easy as when using matplotlib. Problems:

  • Visually, added the colorbar object in figure.axes shows it in pop-up but I cannot figure out how to make it appear in Plot Options without popping things out. Not sure which figure axis number to adjust here.
  • Visually, not sure how to make the ColorAxis span entire plot width. bqplot examples do not dive so deeply and not obvious from API doc.
  • Would be nice if I can just use plugin.viewer.selected_obj._composite_image.scale_image as the ColorScale for ColorAxis but it does not seem to faithfully represent what glue is rendering in the image viewer.
  • In ColorScale (that is actually from yet another package called bqscales), scheme follows Colorbrewer names, not glue names. So, "gray" in glue does nothing. I have to use "Greys" as understood by Colorbrewer. Where is the mapping between glue and Colorbrewer for this?
  • In ColorScale, scale_type only allows "linear" (according to bqscales), so the colorbar refuses to update when non-linear function is given. Forcefully setting plugin.stretch_histogram.figure.axes[2].scale.scale_type = "sqrt" would throw TraitError: The 'scale_type' trait of a ColorScale instance expected any of ['linear'], not the str 'sqrt'.

Screenshot 2023-10-16 143041

As it currently stands, I am actually not sure if we can use this without upstream fix(es).

Refs:

Somewhat related PR(s):

Change log entry

  • Is a change log needed? If yes, is it added to CHANGES.rst? If you want to avoid merge conflicts,
    list the proposed change log here for review and add to CHANGES.rst before merge. If no, maintainer
    should add a no-changelog-entry-needed label.

Checklist for package maintainer(s)

This checklist is meant to remind the package maintainer(s) who will review this pull request of some common things to look for. This list is not exhaustive.

  • Are two approvals required? Branch protection rule does not check for the second approval. If a second approval is not necessary, please apply the trivial label.
  • Do the proposed changes actually accomplish desired goals? Also manually run the affected example notebooks, if necessary.
  • Do the proposed changes follow the STScI Style Guides?
  • Are tests added/updated as required? If so, do they follow the STScI Style Guides?
  • Are docs added/updated as required? If so, do they follow the STScI Style Guides?
  • Did the CI pass? If not, are the failures related?
  • Is a milestone set? Set this to bugfix milestone if this is a bug fix and needs to be released ASAP; otherwise, set this to the next major release milestone.
  • After merge, any internal documentations need updating (e.g., JIRA, Innerspace)? 🐱

@pllim pllim added this to the 3.8 milestone Oct 16, 2023
@maartenbreddels
Copy link
Collaborator

I'm wondering if it makes sense to use the ColorScale of bqplot, and instead create a small bqplot figure and draw the image ourselves. I think glue does most of the value->rgb mapping itself, and I think it's going to be difficult to get feature parity between the ColorScale and Glue.

@pllim
Copy link
Contributor Author

pllim commented Oct 17, 2023

Turns out I am in the wrong rabbit hole. SMEs said we should not use ColorScale. Kyle suggested alternative using matplotlib + histogram colors=. I want to keep what I have here for future reference, so I am going to close this and open a new PR.

@pllim pllim closed this Oct 17, 2023
@pllim pllim deleted the colors-of-the-hist branch October 17, 2023 18:33
@pllim pllim mentioned this pull request Oct 17, 2023
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants