Change line color violon plolty graph object

Marc

I'd like to erase/make transparent the line of each violin. In the photo, they are all in yellow (planning to define the color of each later) but I don't want the colored line round them.

events_name = ["Yellow card", "Red card", "2nd yellow -> Red card", "Goal", "Penalty", "substitution"]

fig = go.Figure()
for index, event in enumerate(events):
    fig.add_trace(go.Violin(x=df_events['description'][df_events['description'] == event],
                            y=df_events['mn'][df_events['description'] == event],
                            name=events_name[index],
                            meanline_visible=True, 
                            bandwidth=0.9, fillcolor="yellow"))


fig.update_layout(title=f"Distribution of events over 90 minutes - ")
fig.update_xaxes(
        title_text = "Event", 
tickvals=[0, 1, 2, 3, 4, 5], 
ticktext=events_name)

fig.update_yaxes(
        title_text = "Minutes of the game",
        tickvals=list(range(0, 105, 15)))

fig.show()

enter image description here

Rob Raymond
  • have simulated you data to make this a repeatable example
  • simply set line_color to plot background color
import plotly.graph_objects as go

events_name = ["Yellow card", "Red card", "2nd yellow -> Red card", "Goal", "Penalty", "substitution"]
events = events_name
df_events = pd.DataFrame({"description":np.random.choice(events, 200), "mn":np.random.uniform(200)})

fig = go.Figure()
for index, event in enumerate(events):
    fig.add_trace(go.Violin(x=df_events['description'][df_events['description'] == event],
                            y=df_events['mn'][df_events['description'] == event],
                            name=events_name[index],
                            meanline_visible=True, 
                            line_color=fig.layout["template"]["layout"]["plot_bgcolor"],
                            bandwidth=0.9, fillcolor="yellow"))


fig.update_layout(title=f"Distribution of events over 90 minutes - ")
fig.update_xaxes(
        title_text = "Event", 
tickvals=[0, 1, 2, 3, 4, 5], 
ticktext=events_name)

fig.update_yaxes(
        title_text = "Minutes of the game",
        tickvals=list(range(0, 105, 15)))

fig.show()

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related