我可以在极坐标条形图中制作分组条形吗?

发布于 2025-01-14 11:35:52 字数 1368 浏览 3 评论 0原文

我有一个极坐标条形图,其中有堆积条形图,这也使用我添加的代码给出了下图(此处找到的示例:风行图):

在此处输入图像描述

import plotly.io as pio
pio.renderers.default = 'svg'
#pio.renderers.default = 'browser'

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

df = px.data.wind()

fig = px.bar_polar(df, r="frequency", theta="direction",
                    color="strength", template="ggplot2",
                    color_discrete_sequence= px.colors.sequential.Plasma_r)
fig.show()


fig.update_layout(legend=dict(
    orientation="h",
    yanchor="top",
    y=-0.2,
    xanchor="center",
    x=0.5),
    polar=dict(radialaxis=dict(showticklabels=True, ticks='', dtick=1, linewidth=0)
    )
)

fig.update_polars(angularaxis_dtick=1, 
                  angularaxis_exponentformat="power")

fig.show()

现在,我想将一些条形图分组在一起,类似于下图(示例 python 图库):

在此处输入图像描述

我无法弄清楚如何用情节来做到这一点我保留了堆积条和分组。任何提示或建议将不胜感激。

谢谢!

I have a polar bar chart with stacked bars in plotly, which gives me the figure below using the code I've added as well (example found here: Wind Rode Charts):

enter image description here

import plotly.io as pio
pio.renderers.default = 'svg'
#pio.renderers.default = 'browser'

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

df = px.data.wind()

fig = px.bar_polar(df, r="frequency", theta="direction",
                    color="strength", template="ggplot2",
                    color_discrete_sequence= px.colors.sequential.Plasma_r)
fig.show()


fig.update_layout(legend=dict(
    orientation="h",
    yanchor="top",
    y=-0.2,
    xanchor="center",
    x=0.5),
    polar=dict(radialaxis=dict(showticklabels=True, ticks='', dtick=1, linewidth=0)
    )
)

fig.update_polars(angularaxis_dtick=1, 
                  angularaxis_exponentformat="power")

fig.show()

Now, I would like to group some bars together, similar to the figure below (examples python graph gallery):

enter image description here

I cannot figure out how to do this with plotly so I keep both the stacked bars AND the grouping. Any hint or suggestions would be highly appreciated.

Thanks!

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文