Reputation: 3829
I've a data frame in pandas having x, count and colors columns.
x count colors
1 4 #99d594
1 4 #99d594
2 3 #ffffbf
I want to plot a bar chart having x on x-axis and count on y-axis and colors column define color for x column respectively.
plt = Bar(df, label='count', title="Bar chart", legend='top_left', color="colors")
But Bokeh doesn't uses the given color codes in colors column. It uses their own itself but #99d594 and #ffffbf are different in colors. .
Pseudo Code:
df = pd.DataFrame( {"x": [1,1,2],
"count": [4,4,5],
"colors": ["#99d594", "#99d594", "#ffffbf"] } )
plt = Bar(df, label='count', title="Bar chart",
plot_width=700, plot_height=300, legend='top_left', color="colors")
output_file("test.html")
Upvotes: 2
Views: 2923
Reputation: 320
Change for:
palette=[ "#99d594", "#ffffbf"]
plt = Bar(df, label='count', title="Bar chart",
plot_width=700, plot_height=300, legend='top_left',
color=color( columns='colors', palette=palette, sort=False))
output_file("test.html")
Should do what you expect :)
Upvotes: 3