gpt4 book ai didi

plot - 如何从 Plotly 中删除轴和数字

转载 作者:行者123 更新时间:2023-12-03 18:30:49 28 4
gpt4 key购买 nike

我有下面这张图,我想把除点和三角形以外的所有东西都去掉,意思是横纵轴上的数字和小竖线,我该怎么做?

这是图片:

Triangle

这是我的代码:

x0 = np.average(triangleEdges,axis=0,weights=np.array([0.2,0.1,0.7]))[0]
y0 = np.average(triangleEdges,axis=0,weights=np.array([0.2,0.1,0.7]))[1]

x1 = np.average(triangleEdges,axis=0,weights=np.array([0.5,0.1,0.7]))[0]
y1 = np.average(triangleEdges,axis=0,weights=np.array([0.5,0.1,0.7]))[1]


trace0 = go.Scatter(
x=[x0],
y=[y0],
marker = dict(
size = 15,
color = 'rgba(25, 181, 254, 1)',
line = dict(
width = 1,
color = 'rgb(0, 0, 0)'
)
)
)

trace1 = go.Scatter(
x=[x1],
y=[y1],
marker = dict(
size = 15,
color = 'rgba(152, 0, 0, .8)',
line = dict(
width = 1,
color = 'rgb(0, 0, 0)'
)
)
)


data = [trace0,trace1]
layout = {

'xaxis': {

'range': [0.2, 1],
'zeroline': False,
},
'yaxis': {
'range': [0, 1],
'showgrid': False,
},
'shapes': [


# filled Triangle
{
'type': 'path',
'path': ' M 0.2 0 L 1 0 L 0.6 1 Z',
'fillcolor': 'rgba(44, 160, 101, 0.5)',
'line': {
'color': 'rgb(44, 160, 101)',
},
},

]
}
fig = {
'data': data,
'layout': layout,
}

py.iplot(fig, filename='shapes-path')

我试图环顾四周,但我什么也没找到。

非常感谢!

最佳答案

要关闭轴:

'xaxis': {
'range': [0.2, 1],
'showgrid': False, # thin lines in the background
'zeroline': False, # thick line at x=0
'visible': False, # numbers below
}, # the same for yaxis

同样,如果您想删除图例:
layout = {
'showlegend': False,
...

关于plot - 如何从 Plotly 中删除轴和数字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54826436/

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