亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

斧頭反轉時無法設置范圍-plotly

斧頭反轉時無法設置范圍-plotly

炎炎設計 2023-06-20 15:17:11
我無法調整軸的范圍:我有layout1= go.Layout(title=go.layout.Title(text="A graph",x=0.5),? ? ? ? xaxis={'title':'y[m]','range':[-10,10]},? ? ? ? yaxis={'title':'x[m]', 'side':'right'})# switch the x- and y-coordinatespoint_plot=[? ? ? ? ? ? go.Scatter(y=[3],x=[1],name="V0"),? ? ? ? ? ? go.Scatter(y=[5],x=[2],name="GT"),? ? ? ? ? ? go.Scatter(y=[0],x=[0],name="egoCar")? ? ]fig = go.Figure(data=point_plot, layout=layout1)# reverse the range of the xaxis (which contains the y values)fig.update_xaxes(autorange="reversed")fig.show()如您所見,我希望 Y 軸(現在是水平的)從 -10 變為 10 但是,我得到所以顯然范圍不工作。我想這是因為“autorange”,但我需要這個,因為 ax Y 需要反轉。我怎樣才能做到這一點?
查看完整描述

1 回答

?
喵喔喔

TA貢獻1735條經驗 獲得超5個贊

我找到了答案。顯然要反轉軸,您不需要自動調整它的范圍,而只需向后設置范圍


layout1= go.Layout(title=go.layout.Title(text="A graph",x=0.5),

#        xaxis={'title':'y[m]','autorange':'reversed','range':[-10,10]},

        xaxis={'title':'y[m]'},

        yaxis={'title':'x[m]', 'side':'right'})


# switch the x- and y-coordinates

point_plot=[

            go.Scatter(y=[3],x=[1],name="V0"),

            go.Scatter(y=[5],x=[2],name="GT"),

            go.Scatter(y=[0],x=[0],name="egoCar")

    ]



fig = go.Figure(data=point_plot, layout=layout1)


# reverse the range of the xaxis (which contains the y values)

#fig.update_xaxes(autorange="reversed")

fig.update_xaxes(range=[10,-10])  #BACKWARDS

fig.show()


查看完整回答
反對 回復 2023-06-20
  • 1 回答
  • 0 關注
  • 123 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號