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

[FEATURE] Add method to construct a ColorBar #12736

Closed
tcmetzger opened this issue Jan 13, 2023 · 1 comment · Fixed by #12753
Closed

[FEATURE] Add method to construct a ColorBar #12736

tcmetzger opened this issue Jan 13, 2023 · 1 comment · Fixed by #12753
Assignees
Labels
python Issues that should only require updating Python code reso: completed tag: API: plotting type: feature
Milestone

Comments

@tcmetzger
Copy link
Member

As discussed with @bryevdv, we don't have a simple way to create a ColorBar when using linear_cmap() or log_cmap() (i.e. without explicitly importing and defining a ColorBar object).

The following code works, but it would be good to have an explicit method for this, similar to the construct method for the contour renderer.

r = plot.circle(x, y, color=linear_cmap('y', 'Turbo256', min(y), max(y)), size=10)
color_bar = ColorBar(color_mapper=r.glyph.fill_color.transform)
mapper_plot.add_layout(obj=color_bar, place="right")

Optimally, this should work like this:

r = plot.circle(...)
color_bar = r.construct_color_bar()

The construct_color_bar method would take some arguments, including an argument to define if the color_bar should use the mapper associated with a glyph's line or fill color (default to fill color). There also needs to be an error check to verify that the fill_color or line_color is a transform with a colormapper.

@bryevdv bryevdv self-assigned this Jan 13, 2023
@bryevdv bryevdv added the python Issues that should only require updating Python code label Jan 28, 2023
@bryevdv bryevdv added this to the 3.1 milestone Jan 28, 2023
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
python Issues that should only require updating Python code reso: completed tag: API: plotting type: feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants