plot - 如何从 Plotly 中删除轴和数字
问题描述
我有下面的图片,我想删除除了点和三角形之外的所有东西,这意味着水平和垂直轴上的数字以及小的垂直线,我该怎么做?
这是图片:
这是我的代码:
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,
...
推荐阅读
- php - Firefox 中未返回 Cookie 值
- react-native - expo 是 CocoaPods 的 windows 版本吗?
- reactjs - 创建一个 SearchBar,在用户提交搜索后,显示该标题的所有匹配项(或部分匹配项)
- r - 按小时分钟从最早到最晚的升序排列我的df
- html - 我希望菜单在最小化到移动屏幕后变成汉堡包图标
- python - 二叉搜索树顺序不起作用(python)
- node.js - socket.io:监听事件
- python - 如何使用 SQL 将文字表合并到雪花中的现有表中
- c# - 无法从字符串转换为 NewtonSoft.Json.JsonReader
- c++ - 什么时候在 lambda 函数中释放变量副本?