在Python中以绘图方式概述绘图区域

wor*_*ise 4 python plotly

我已经做了一个图,例如:

import plotly.plotly as py
import plotly.graph_objs as go

trace1 = go.Scatter(
    x=[1, 2, 3, 4, 5, 6, 7],
    y=[7, 6, 5, 4, 3, 2, 1]
)
trace2 = go.Scatter(
    x=[1, 2, 3, 4, 5, 6, 7, 8],
    y=[1, 2, 3, 4, 5, 6, 7, 8]
)
data = [trace1, trace2]
layout = dict(xaxis = dict(title = 'T (K)', showgrid=False, ticks='inside'),
                yaxis = dict(title = 'normalized intensity', showgrid=False, ticks='inside'),
                font=dict(size=18),
                )
fig = go.Figure(data=data, layout=layout)
py.iplot(fig, auto_open=True, filename='test_fig.png')
py.image.save_as(fig, filename='test_fig.png')
Run Code Online (Sandbox Code Playgroud)

该图看起来像:

测试图

我想要这样的绘图区域轮廓:

无花果概述

但到目前为止,我仍无法从plot.ly文档中得出答案。这可能吗?

Max*_*ers 7

您所需要做的就是找到另一个隐藏良好的Plotly属性。在这种情况下是mirror

mirror (enumerated: True | "ticks" | False | "all" | "allticks" )

确定轴线或/和刻度线是否镜像到绘图区域的另一侧。如果为“ True”,则轴线是镜像的。如果为“刻度线”,则轴线和刻度线是镜像的。如果为“ False”,则禁用镜像。如果为“全部”,则轴线将镜像到所有共享轴子图上。如果为“ allticks”,则轴线和刻度线将反映在所有共享轴子图上。

mirror=True,
ticks='outside',
showline=True,
Run Code Online (Sandbox Code Playgroud)

到您xaxisyaxis dicts您将得到以下图形。

在此处输入图片说明

  • 哈哈谢谢。我会说“隐藏良好”不是编程库的方法/属性的良好属性。 (4认同)
  • @wordsforthewise:对于 Plotly 的辩护,它显示在示例页面上,但谷歌搜索不会帮助你,因为缺少必要的关键字。https://plot.ly/python/axes/#styling-and-coloring-axes-and-the-zeroline (2认同)