How can I specify bar colour using plotly as backend?

I’m trying to use the plotly backend to make some bar charts and I want to specify the colour of the bars. But when I do that I get the following error;

Option 'color' for Bars type not valid for selected backend ('plotly')

What option do I specify instead?

1 Like

No replies?

I have same problem.
I did ask question on stackoverflow. Maybe there will be solution you are looking for.

I have reported the issue here color option not working for Bars plot with Plotly backend · Issue #5658 · holoviz/holoviews (github.com)

Please upvote if you think its important.

Hi @Marc,

Silly one here, I’m not familiar with GitHub even though registered, I couldn’t see how to upvote is it an actual button or leaving a comment?

I was playing with the code yesterday after saw this, I can see the options for the plotly backend does not exist currently which I guess is why it does not work.

import pandas as pd
import holoviews as hv
hv.extension("bokeh")

data = pd.DataFrame({
    "framework": ["hvPlot", "HoloViews", "Panel"], 
    "stars": [700, 2400, 2600]
})
plot = hv.Bars(data, kdims="framework", vdims="stars").opts(ylabel="⭐", width=1000) # no color provided with bokeh backend color defaults to color=Cycle()

import panel as pn
pn.extension()
pn.panel(plot).servable()

With color specified, in this case color = “gold”, Cycle() is replaced with gold under the Bokeh backend

Now if change to plotly backend as others have tried you can see the color option doesn’t exist for user to pass something too and includes a friendly warning at least with the versions of imports I’m making use of.

I saw that code for changing color in plotly bar can accept single or list and also you can base it on column names of the dataframe but I think this is then auto colouring. I guess I was just looking here to see that plotly could indeed change the colour of the bars at user digression because some of it is very automagic.

1 Like

Hi @carl

Github has no clear upvote. But what people normally do is react as below or leave a “+1” reply.

image