Possible bug color_discrete_map and opacity in px.pie (plotly.io as pio)

Iā€™m using pio.show(pie_fig) to plot my pie_fig. My version of plotly is 4.5.0. but color_discrete_map and opacity are not working when I use the documentation examples here:

df = px.data.tips()
fig = px.pie(df, values='tip', names='day', color='day',
             color_discrete_map={'Thur':'lightcyan',
                                 'Fri':'cyan',
                                 'Sat':'royalblue',
                                 'Sun':'darkblue'})
pio.show(fig)

The colors donā€™t change. I get the default colors. And inā€¦

df = px.data.tips()
fig = px.pie(df, values='tip', names='day', opacity=0.4, color_discrete_sequence=px.colors.sequential.RdBu)
pio.show(fig)

opacity raises this error:

ValueError: Invalid property specified for object of type plotly.graph_objs.pie.Marker: ā€˜opacityā€™
Valid properties:
colorsā€¦
colorssrcā€¦
lineā€¦

Is this a bug or am I going crazy?

Hi @adamschroeder

With Plotly 4.5.4 the color_discrete_map works:

Fig1

but opacity is still an Invalid property. You should open an issue.

1 Like

Sorry about this! That argument should not be there, as indeed marker opacity is not supported in the underlying rendering systemā€¦ Should be fixed in the next version: https://github.com/plotly/plotly.py/pull/2294

1 Like

@nicolaskruchten I have no experience with plotly express I just pasted the code above in my notebook. After running, it was displayed that opacity is an invalid property. Then I typed help(px.pie) and opacity was listed as a pie attribute.
Thatā€™s why I suggested to open an issue. Iā€™m sorry!!!

@empet thereā€™s nothing to apologize for! There is indeed a bug here: the opacity argument in px.pie should not be there and recommending to open an issue is the right thing to do :slight_smile:

In this case I saw this post and opened a pull request immediately to save time but I donā€™t read as many forum posts as I would like so the ā€œopen an issueā€ plan is always a safe bet!

Thanks!