简体   繁体   English

Plotly Scatterpolar 改变填充、线条和 hover 颜色

[英]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})

例子

Add the same color to the line so that the hover color will also be the same.为该行添加相同的颜色,这样 hover 的颜色也将相同。 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})

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM