User981636
User981636

Reputation: 3621

Plotly Scatterpolar change fill, line and hover color

I have the following example. I can change the fill color to 'green' following the documentation but I cannot find how to change the line/dots and tooltip colours to the same one. What's the best way to change all into one colour?

import numpy as np
import pandas as pd
import plotly.express as px

df = px.data.wind()
df_test = df[df["strength"]=='0-1']
fig.data=[]
fig.add_trace(go.Scatterpolar(r=df_test['frequency'], theta=df_test['direction'],fill='toself',fillcolor='green'))

fig.show(config= {'displaylogo': False})

Example

Upvotes: 3

Views: 1999

Answers (1)

r-beginners
r-beginners

Reputation: 35115

Add the same color to the line so that the hover color will also be the same. I then disabled the grid on the graph to match the image presented.

import pandas as pd
import plotly.graph_objects as go

df = px.data.wind()
df_test = df[df["strength"]=='0-1']

fig = go.Figure()

fig.add_trace(go.Scatterpolar(r=df_test['frequency'],
                              theta=df_test['direction'],
                              fill='toself',
                              fillcolor='green',
                              line_color='green',
                             ))

fig.update_layout(polar=dict(radialaxis=dict(visible=False)))

fig.show(config= {'displaylogo': False})

enter image description here

Upvotes: 2

Related Questions