Color bars

ipyscales includes widgets for visualising color maps as color bars, and for manually editing color maps.

Let’s define two simple color maps first:

import ipyscales
from ipyscales._example_helper import use_example_model_ids
cm = ipyscales.LinearColorScale(
    range=('blue', 'green'),
    domain=(1000, 5000)
cm_div = ipyscales.LinearColorScale(
    range=('blue', 'white', 'red'),
    domain=(-1, 0, 1)

Next, let us define a color bar for the first color map:

colorbar = ipyscales.ColorBar(colormap=cm, length=300)
assert colorbar.colormap is cm

The orientation of the color bar can be made horizontal as well:

ipyscales.ColorBar(colormap=cm_div, length=300, orientation='horizontal')

The color map can include transparent colors, and the color bar also supports this:

cm_div_transp = ipyscales.LinearColorScale(
    range=('rgba(0, 0, 255, 0.5)', 'white', 'rgba(255, 0, 0, 0.5)'),
    domain=(-1, 0, 1)
ipyscales.ColorBar(colormap=cm_div_transp, length=200)

The editor ColorMapEditor can be used to manually edit the color map. The actions you can do are: - Change the color of a stop by double-clicking the corresponding handle. - Change the location of stops by dragging the handles.

    colormap=cm_div_transp, length=400, orientation='horizontal')

Future features planned for the editor include: - Adding new stops. - Removing stops. - Modifying the stop location by numeric input. - UI for changing opacity of a color stop.