Skip to content

Linked scatter plots colored by different dimensions #3935

@joshua-gould

Description

@joshua-gould

I'm trying to create 2 linked scatter plots in Holoviews. Each of the scatter plots is colored by a different dimension. Using Holoviews, setting shared_datasource=True causes the second plot to use the color dimension for the first plot. The same plot using bokeh directly works fine.

from bokeh.io import show
from bokeh.layouts import gridplot
from bokeh.models import ColumnDataSource
from bokeh.plotting import figure
import pandas as pd
import holoviews as hv
from holoviews import opts
hv.extension('bokeh')

# create data
df = pd.DataFrame(data=dict(x=[1,2,3], y=[1,2,3], c1=['red', 'green', 'blue'], c2=['blue', 'green', 'blue']))

# create plot with bokeh directly
source = ColumnDataSource(df)
TOOLS = "box_select"
left = figure(tools=TOOLS, plot_width=300, plot_height=300)
left.circle('x', 'y', source=source, color='c1')
right = figure(tools=TOOLS, plot_width=300, plot_height=300)
right.circle('x', 'y', source=source, color='c2')
p = gridplot([[left, right]])
show(p)

# create plot with holoviews
scatter1 = hv.Points(df, kdims=['x', 'y'], vdims=['c1', 'c2']).opts(color='c1')
scatter2 = hv.Points(df, kdims=['x', 'y'], vdims=['c1', 'c2']).opts(color='c2',)
(scatter1 + scatter2).opts(opts.Layout(shared_datasource=True), opts.Points(size=8,  padding=0.05, tools=['box_select']))

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugSomething isn't correct or isn't working

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions