I currently have a BoxPlot created in Plotly Express, as seen below
which uses the code:
import plotly.express as px
fig = px.box(df, x="issuer.operator.name", y="validity_period", points='all', log_y=True,
width=2000, height=1000,
template="simple_white")
fig.show()
However, I am trying to create the chart such that each box plot is shown in a different color based on the x-axis objects (i.e. Internet Sec Research Group is Blue, Sectigo is red, etc).
I know from this post that you can use the parameter color= '<column heading>'
to choose how the graph is coloured. From the docs, the parameter color is
Either a name of a column in data_frame, or a pandas Series or array_like object. Values from this column or array_like are used to assign color to marks.
However, when I try to run the code with the additional color parameter such that
import plotly.express as px
fig = px.box(df, x="issuer.operator.name", y="validity_period", color="issuer.operator.name", points='all', log_y=True,
width=2000, height=1000,
template="simple_white")
fig.show()
I recieve the following error:
KeyError: (nan, '', '', '')
How would I go about changing each boxplot's color? Appreciate any help.