如何为该雷达图添加标题?

时间:2021-04-30 10:06:06

标签: python python-3.x plotly

import plotly.graph_objects as go
import plotly.express as px


df = px.data.iris()


categories = ['PSxG-GA','Goals Against','Save %',
              'Clean Sheet %', 'Save %(penalty)']

fig = go.Figure()

fig.add_trace(go.Scatterpolar(
      r=[79, 79, 85, 86, 19],
      theta=categories,
      fill='toself',
      name='MATS'
))
fig.add_trace(go.Scatterpolar(
      r=[89, 96, 92, 95, 81],
      theta=categories,
      fill='toself',
      name='Oblak'
))


fig.update_layout(
  polar=dict(
    radialaxis=dict(
      visible=True,
      range=[0, 100]
    )),
  showlegend=False
)

fig.show()

这就是结果。 enter image description here

我正在尝试制作比较两个足球运动员 Ter Stegen 和 Oblak 的雷达图。我已经制作了图表,但正在努力添加标题并指定哪种颜色适合旁边的人。

1 个答案:

答案 0 :(得分:0)

您可以使用:

fig.update_layout(title_text = 'Title')

或者:

fig.update_layout(title = dict(text = 'Title'))

情节

enter image description here

相关问题