I have two variables of the same unit I want to plot on the same x-axis with Bokeh. Seems like plot.multi_line is the right tool but I can't find the right syntax from the doc. What I tried (gathered from doc):
# df is a pandas DataFrame with contains 3 columns x, y1, y2
source = ColumnDataSource(data=df)
plot=figure()
plot.multi_line(['x','x'], ['y1', 'y2'], source=source)
Alternatively tried:
plot.multi_line(xs=['x','x'], ys=['y1', 'y2'], source=source)
Results in
RuntimeError: Supplying a user-defined data source AND iterable values to glyph methods is not possibe. Either:
Pass all data directly as literals:
p.circe(x=a_list, y=an_array, ...)
Or, put all data in a ColumnDataSource and pass column names:
source = ColumnDataSource(data=dict(x=a_list, y=an_array)) p.circe(x='x', y='x', source=source, ...)
Doc give this example:
p.multi_line([[1, 3, 2], [3, 4, 6, 6]], [[2, 1, 4], [4, 7, 8, 5]],
color=["firebrick", "navy"], alpha=[0.8, 0.3], line_width=4)
I obviously don't want to pass the values with raw lists. I don't get it, I need a little help.
Ok, I feel silly, simply doing:
source = ColumnDataSource(data=df)
plot=figure()
plot.line('x','y1', source=source, line_color="red")
plot.line('x','y2', source=source, line_color="blue")
does the trick, as it would do in Matplotlib... I got confused with this "plot.multi_line" function (I now don't get why I would used that, but well).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With