如何创建阿拉伯图表? (P从右到左的x轴)和Plotly

时间:2018-06-12 21:53:01

标签: python graph charts plotly

我想从右到左开始在x轴上绘图(对于阿拉伯图表)。所以我需要右下角的(x,y)=(0,0)。 有可能在python上用plotly做吗?怎么样?

2 个答案:

答案 0 :(得分:0)

使用递减x轴参数。

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()

答案 1 :(得分:0)

在Python中使用Plotly软件包:

假设我们有一个法线图(实际图,实际yaxis1-left,实际yaxis2-right,实际xaxis),我们需要将实际yaxis1-left放置在右侧,而将实际yaxis2-right放置在左侧,并反转xaxis。 为此,我们使用代码:

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')

我希望这会有所帮助^ _ ^