gpt4 book ai didi

python - 在Python中以绘图方式勾勒出绘图区域

转载 作者:行者123 更新时间:2023-12-03 20:21:48 24 4
gpt4 key购买 nike

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

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

该图看起来像:

test figure

我想要一个绘图区的轮廓,如下所示:

outlined fig

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

最佳答案

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

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

Determines if the axis lines or/and ticks are mirrored to the opposite side of the plotting area. If "True", the axis lines are mirrored. If "ticks", the axis lines and ticks are mirrored. If "False", mirroring is disable. If "all", axis lines are mirrored on all shared-axes subplots. If "allticks", axis lines and ticks are mirrored on all shared-axes subplots.



添加
mirror=True,
ticks='outside',
showline=True,

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

enter image description here

关于python - 在Python中以绘图方式勾勒出绘图区域,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42096292/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com