在图中显示雷达图上的数据点

发布于 2025-02-13 09:27:02 字数 1462 浏览 3 评论 0原文

我找不到有关如何显示数据点的答案(请参阅r go.scatterpolar中指示)。也许有人知道如何实现这一目标?

此外,从0-5的数字奇怪地旋转,我找不到解决方法的方法。 任何提示,评论和建议都将不胜感激。

这是一个虚拟代码:

import plotly.graph_objects as go
from plotly.subplots import make_subplots

fig = go.Figure()

question= ["Q1", "Q2","Q3", "Q4"]

fig = make_subplots(rows=2, cols=2, specs=[[{'type': 'polar'}] * 2] * 2)

fig.add_trace(
    go.Scatterpolar(
        theta= question, #question
        r=[5.60, 5.62, 5.60, 5.59], 
        name = "Graph 1"
    ),
    row=1,
    col=1,
)
    
fig.add_trace(
    go.Scatterpolar(
        theta= question, #question
        r=[5.60, 5.62, 5.60, 5.59], 
        name = "Graph2"
    ),
    row=1,
    col=2,
)
fig.add_trace(
    go.Scatterpolar(
        theta= question, #question
        r=[5.60, 5.62, 5.60, 5.59], 
        name = "Graph3"
    ),
    row=2,
    col=1,
)
    
fig.add_trace(
    go.Scatterpolar(
        theta= question, #question
        r=[5.60, 5.62, 5.60, 5.59],
        name = "Graph4"
    ),
    row=2,
    col=2,
)


这是plitly中的雷达图:

”输入图像描述在这里”

理想情况下,我想以一种优雅的方式显示图表外的值,以免混乱。看到我在下面的油漆中不良尝试。如果那不起作用,其他任何东西也可以

I cannot find an answer on how to display the data points (see r indicated in go.Scatterpolar). Maybe someone has an idea how to achieve that?

Additionally, the numbers from 0-5 are oddly rotated, and I cannot find a way on how to fix it.
Any hints, comments, and suggestions would be highly appreciated.

This is a dummy code:

import plotly.graph_objects as go
from plotly.subplots import make_subplots

fig = go.Figure()

question= ["Q1", "Q2","Q3", "Q4"]

fig = make_subplots(rows=2, cols=2, specs=[[{'type': 'polar'}] * 2] * 2)

fig.add_trace(
    go.Scatterpolar(
        theta= question, #question
        r=[5.60, 5.62, 5.60, 5.59], 
        name = "Graph 1"
    ),
    row=1,
    col=1,
)
    
fig.add_trace(
    go.Scatterpolar(
        theta= question, #question
        r=[5.60, 5.62, 5.60, 5.59], 
        name = "Graph2"
    ),
    row=1,
    col=2,
)
fig.add_trace(
    go.Scatterpolar(
        theta= question, #question
        r=[5.60, 5.62, 5.60, 5.59], 
        name = "Graph3"
    ),
    row=2,
    col=1,
)
    
fig.add_trace(
    go.Scatterpolar(
        theta= question, #question
        r=[5.60, 5.62, 5.60, 5.59],
        name = "Graph4"
    ),
    row=2,
    col=2,
)


Here is the radar graph in plotly:

enter image description here

Ideally I would like to have an elegant way of showing the values outside the graph, so that it is not cluttered. See my poor attempt in Paint below. If that doesn't work, anything else is also fine

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

爱冒险 2025-02-20 09:27:02

极性坐标中的散点图与常规散点图相同,并且具有一个模式,因此可以通过设置线和字符串来显示它们。绳子位于顶部的中心。要调整当时的比例,请在布局更新中设置轴范围。

import plotly.graph_objects as go
from plotly.subplots import make_subplots

fig = go.Figure()

question= ["Q1", "Q2","Q3", "Q4"]

fig = make_subplots(rows=2, cols=2, specs=[[{'type': 'polar'}] * 2] * 2)

fig.add_trace(
    go.Scatterpolar(
        mode='lines+text',
        theta= question, #question
        r=[5.60, 5.62, 5.60, 5.59], 
        name = "Graph 1",
        text=[5.60, 5.62, 5.60, 5.59],
        textposition='top center'
    ),
    row=1,
    col=1,
)
    
fig.add_trace(
    go.Scatterpolar(
        mode='lines+text',
        theta= question, #question
        r=[5.60, 5.62, 5.60, 5.59], 
        name = "Graph2",
        text=[5.60, 5.62, 5.60, 5.59],
        textposition='top center'
    ),
    row=1,
    col=2,
)
fig.add_trace(
    go.Scatterpolar(
        mode='lines+text',
        theta= question, #question
        r=[5.60, 5.62, 5.60, 5.59], 
        name = "Graph3",
        text=[5.60, 5.62, 5.60, 5.59],
        textposition='top center'
    ),
    row=2,
    col=1,
)
    
fig.add_trace(
    go.Scatterpolar(
        mode='lines+text',
        theta= question, #question
        r=[5.60, 5.62, 5.60, 5.59],
        name = "Graph4",
        text=[5.60, 5.62, 5.60, 5.59],
        textposition='top center'
    ),
    row=2,
    col=2,
)

fig.update_layout(autosize=False,
                  height=600,
                  polar=dict(radialaxis=dict(range=[0,6])),
                  polar2=dict(radialaxis=dict(range=[0,6])),
                  polar3=dict(radialaxis=dict(range=[0,6])),
                  polar4=dict(radialaxis=dict(range=[0,6])),
)
fig.show()

Scatter plots in polar coordinates are the same as regular scatter plots and have a mode so that they can be displayed by setting the line and string. The string is positioned at the center of the top. To adjust the scale at that time, set the axis range in the layout update.

import plotly.graph_objects as go
from plotly.subplots import make_subplots

fig = go.Figure()

question= ["Q1", "Q2","Q3", "Q4"]

fig = make_subplots(rows=2, cols=2, specs=[[{'type': 'polar'}] * 2] * 2)

fig.add_trace(
    go.Scatterpolar(
        mode='lines+text',
        theta= question, #question
        r=[5.60, 5.62, 5.60, 5.59], 
        name = "Graph 1",
        text=[5.60, 5.62, 5.60, 5.59],
        textposition='top center'
    ),
    row=1,
    col=1,
)
    
fig.add_trace(
    go.Scatterpolar(
        mode='lines+text',
        theta= question, #question
        r=[5.60, 5.62, 5.60, 5.59], 
        name = "Graph2",
        text=[5.60, 5.62, 5.60, 5.59],
        textposition='top center'
    ),
    row=1,
    col=2,
)
fig.add_trace(
    go.Scatterpolar(
        mode='lines+text',
        theta= question, #question
        r=[5.60, 5.62, 5.60, 5.59], 
        name = "Graph3",
        text=[5.60, 5.62, 5.60, 5.59],
        textposition='top center'
    ),
    row=2,
    col=1,
)
    
fig.add_trace(
    go.Scatterpolar(
        mode='lines+text',
        theta= question, #question
        r=[5.60, 5.62, 5.60, 5.59],
        name = "Graph4",
        text=[5.60, 5.62, 5.60, 5.59],
        textposition='top center'
    ),
    row=2,
    col=2,
)

fig.update_layout(autosize=False,
                  height=600,
                  polar=dict(radialaxis=dict(range=[0,6])),
                  polar2=dict(radialaxis=dict(range=[0,6])),
                  polar3=dict(radialaxis=dict(range=[0,6])),
                  polar4=dict(radialaxis=dict(range=[0,6])),
)
fig.show()

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文