如何使用Plotly创建阿拉伯语图表?(X轴从右到左)

3

我希望能够在从右到左的方向上开始绘制 x 轴(用于阿拉伯图表)。因此,我需要将 (x, y) = (0, 0) 放在右下角。 在 Python 中是否可以使用 Plotly 实现?如何实现?


2
这是一个matplotlib还是plotly的问题? - Naren Murali
你能用 Plotly 做吗? - McAlixter
@ImportanceOfBeingErnest 这似乎是一个 Plotly 的问题,请检查上面的评论,我们能否再次将其变成一个有效的问题? - Naren Murali
可能是Plotly.js - 如何在plotly中反转水平条形图的重复问题。 - Naren Murali
干得好,不幸的是我不能两次关闭同一个问题(理想情况下我应该在之前就知道这个重复问题,因为替换重复问题是允许的),所以现在需要由审核队列来处理。 - ImportanceOfBeingErnest
显示剩余4条评论
2个回答

1
使用递减的 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()

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

希望这会有所帮助 ^_^


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接