擅长:python、mysql、java
<p>在Python中使用Plotly包:</p>
<p>假设我们有一个正规图(实际图,实际yaxis1 left,实际yaxis2 right,实际xaxis),我们需要将实际yaxis1 left放在右侧,将实际yaxis2 right放在左侧,并反转xaxis。
为此,我们使用以下代码:</p>
<pre><code>import plotly.graph_objs as go
import plotly.offline as py
trace1=go.Bar(
x=[#Your years here],
y=[#Your data here],
name = 'chart1'
)
trace2=go.Scatter(
x=[#your years here],
y=[#your data here],
name = 'chart2',
yaxis='y2'
)
data = [trace1, trace2]
layout = go.Layout(
title="MAIN_TITLE",
xaxis=dict(title="years",
autorange='reversed',
),
yaxis=dict(
title='title1',
side='right',
showline=True
),
yaxis2=dict(
title='title2',
side='left',
showline=True
)
)
fig = go.Figure(data=data, layout=layout)
py.plot(fig, filename='axes-reversed.html')
</code></pre>
<p>我希望这会有帮助</p>