我希望能够在从右到左的方向上开始绘制 x 轴(用于阿拉伯图表)。因此,我需要将 (x, y) = (0, 0) 放在右下角。 在 Python 中是否可以使用 Plotly 实现?如何实现?
我希望能够在从右到左的方向上开始绘制 x 轴(用于阿拉伯图表)。因此,我需要将 (x, y) = (0, 0) 放在右下角。 在 Python 中是否可以使用 Plotly 实现?如何实现?
import matplotlib.pyplot as plt
import numpy as np
t = np.arange(0.01, 5.0, 0.01)
s = np.exp(-t)
plt.plot(t, s)
plt.xlim(5, 0) # decreasing time
plt.xlabel('decreasing time (s)')
plt.ylabel('voltage (mV)')
plt.title('Should be growing...')
plt.grid(True)
plt.show()
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')
希望这会有所帮助 ^_^