I have three list and I want plot a xy scatter plot in bokeh but color of plot points would depend on value of Y but scaled to value specfied in list 'z'. Note here that 'z' is of different size from x and y
How could I do it?
` x = list(range(1, 51)) # Data points
y = random.sample(range(0, 100), 50) # Temperature observed
z = list(range(0, 100)) color bar temp range.
source = ColumnDataSource('.....????..........')
cmap = linear_cmap(field_name='?', palette="Spectral6", low=?, high=?)
r = p.scatter(y, y, color=cmap, size=15, source=source)`
I tried following the example given on "https://docs.bokeh.org/en/latest/docs/examples/basic/data/linear_cmap_colorbar.html" but did not have any success.
Lots going on here that needs attention to get the most out of Bokeh.
1. Data Preparation
Since your 'z' values (representing the scaling factor) have a different range than 'y' (temperature), you need to normalize them. A common approach is min-max normalization:
2. Create a ColumnDataSource
You will need the normalized 'z' values in your data source for the color mapping.
3. Linear Color Mapper
Set the
field_nameto the column in your data source containing the values that will drive the color mapping (in this case, 'temperature'). You might want to scale thelowandhighvalues of the color mapper if there are outliers in your data, ensuring good visual representation.4. Plot and Apply Color Mapping
Like I said a bit going on there and I won't be able to hand-hold it all the way, but understanding these bigger moves on the structure and intent will help you get the last few.