Hi again,
Maybe my intuition is off here, apologies in that case. But consider this example:
import numpy as np
from bokeh.io import curdoc
from bokeh.plotting import Figure
from bokeh.models import ColumnDataSource
xdata, ydata = ,
colors = [’#ff0000’, ‘#00ff00’, ‘#0000ff’]
#markers = [‘circle’, ‘square’, ‘diamond’]
num_x, intercept = 7, 2.5
for slope in [2.5, 3.5, 4.5]:
xdata.append(np.linspace(0, 10, num_x))
ydata.append(intercept + slope*xdata[-1] + np.random.random(num_x))
source = ColumnDataSource(data={‘x’: , ‘y’: , ‘color’: ,
#‘marker’:
})
for idx, (x, y) in enumerate(zip(xdata, ydata)):
source.data[‘x’].extend(list(x))
source.data[‘y’].extend(list(y))
source.data[‘color’].extend([colors[idx]]*len(x))
#source.data[‘marker’].extend([markers[idx]]*len(x))
f = Figure()
f.scatter(
x=‘x’, y=‘y’, source=source, color=‘color’,
#marker=‘marker’
)
curdoc().add_root(f)
``
I would have expected that the uncommented code would work, which it unfortunately does not, it raises an exception:
ValueError: Invalid marker type ‘marker’. Use markers() to see a list of valid marker types.
The marker
kwarg should arguably be analogous with color
kwarg, but this is not the case.
I guess I could create as many different ColumnDataSources as I want markers and loop over markers:
for midx, marker in enumerate(markers):
getattr(f, marker)(x=‘x’, y=‘y’, color=‘color’, source=sources[midx])
``
is that what’s recommended?
Best regards,
Björn Dahlgren