大佬教程收集整理的这篇文章主要介绍了使用 plotly express 绘制多个极坐标线图,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试使用 plotly express 在一个图中绘制 3 个极坐标线图。虽然我可以让每个单独的图都起作用,但在尝试将所有 3 个图绘制为子图时出现错误。我是情节表达的新手,因此对次要情节的工作方式有些困惑。
以下是两次单独的尝试,每次尝试都会收到自己的错误。如果有人能帮助解决其中之一,我将不胜感激。
InDicator variable value
0 Extreme Poverty Agriculture 0.154194
1 Extreme Poverty WASH 0.103432
2 Extreme Poverty Governance 0.383699
3 Extreme Poverty Demographics 0.164442
4 Extreme Poverty Education 0.017159
5 Extreme Poverty Conflict 0.177073
第一次尝试
fig,ax = plt.subplots(311)
#figure 1
fig = px.line_polar(Xmelt,r="value",theta="variable",color="InDicator",line_close=True,range_r = [0,0.4],title ='2025',wIDth=800,height=500,color_discrete_sequence=('#520e05','#898989','#dbd91d'))
#color_discrete_sequence= px.colors.sequential.plasma_r)
fig.update_layout(
polar_radialaxis_ticksuffix='%',polar_angularaxis_rotation=90)
#figure 2
fig = px.line_polar(Hmelt,polar_angularaxis_rotation=90)
#figure 3
#ax3 = fig.add_subplot(133)
fig = px.line_polar(cmelt,0.6],polar_angularaxis_rotation=90)
尝试 1:这里没有错误,但只出现最后一个图表
第二次尝试
from plotly.subplots import make_subplots
import plotly.graph_objects as go
fig = make_subplots(rows=3,cols=1,specs=[{'type': 'polar'}])
trace1 = go.Scatterpolar(
r=Xmelt["value"],theta=Xmelt["variable"],color=Xmelt["InDicator"],'#dbd91d'),row=3,col=1)
#color_discrete_sequence= px.colors.sequential.plasma_r)),3,1)
trace2 = go.Scatterpolar(
r=Hmelt["value"],theta=Hmelt["variable"],color=Hmelt["InDicator"],col=2)
trace3 = go.Scatterpolar(
r=cmelt["value"],theta=cmelt["variable"],color=cmelt["InDicator"],col=3)
fig.show()
尝试 2:此处的错误消息是:make_subplots 的“specs”参数必须是维度为 (3 x 1) 的字典的二维列表。
接收到
谢谢
首先,是不是需要指定plotly库,不知道express中能不能做subplots。 其次,make_subplot 的图形类型需要是列表格式,需要指定需要的绘图数量。
第一次尝试:
import plotly.expess as px
第二次尝试:
fig = make_subplots(rows=3,cols=1,specs=[[{'type': 'polar'}]*3])
以上是大佬教程为你收集整理的使用 plotly express 绘制多个极坐标线图全部内容,希望文章能够帮你解决使用 plotly express 绘制多个极坐标线图所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。