Skip to content

[FEATURE] Add method to construct a ColorBar #12736

Description

@tcmetzger

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.

Metadata

Metadata

Assignees

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions