gpt4 book ai didi

python - 如何使用python绘制彼此相邻的绘图仪表图?

转载 作者:行者123 更新时间:2023-12-04 00:53:35 24 4
gpt4 key购买 nike

我的脚本中有两个仪表图,想并排显示它们。

import plotly.graph_objects as go

fig1 = go.Figure(go.Indicator(mode="gauge+number", value=400, domain={'x': [0, 1], 'y': [0, 1]}, title={'text': "Speed 1"}))

fig2 = go.Figure(go.Indicator(mode="gauge+number", value=250, domain={'x': [0, 1], 'y': [0, 1]}, title={'text': "Speed 2"}))
怎么显示 fig1fig2并排?

最佳答案

您使用 domain 走在正确的轨道上属性,但您的确切规范已关闭。通过下面完整代码中的其余设置,以下规范会生成相关的绘图:
域规范

 domain={'x': [0.0, 0.4], 'y': [0.0, 1]}

domain={'x': [0.6, 1.0], 'y': [0., 1.00]}
阴谋
enter image description here
完整代码
import plotly
import plotly.offline as py
import plotly.graph_objs as go
import plotly.express as px

# traces with separate domains to form a subplot
trace1 = go.Indicator(mode="gauge+number", value=400, domain={'x': [0.0, 0.4], 'y': [0.0, 1]}, title={'text': "Speed 1"})

trace2 = go.Indicator(mode="gauge+number", value=250, domain={'x': [0.6, 1.0], 'y': [0., 1.00]}, title={'text': "Speed 2"})

# layout and figure production
layout = go.Layout(height = 600,
width = 600,
autosize = False,
title = 'Side by side gauge diagrams')
fig = go.Figure(data = [trace1, trace2], layout = layout)
fig.show()

关于python - 如何使用python绘制彼此相邻的绘图仪表图?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64462790/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com