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

标签 plot plotly

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

这是图片:

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/

相关文章:

使用密度绘制 3d 中的 R- xy 散点图

Python 3D 绘图与数据,发生错误

r - 尝试在具有属性的 tmap shapefile 中绘制

python - 在jupyter笔记本中以离线模式使用plotly(使用nbcovert --execute)打开IDE(vscode)

python - Plotly:带有下拉菜单和按组颜色的散点图

graph - gnuplot 对多个条形图进行分组

r - 绘制神经网络图

Plotly Treemap 不能与 go.Treemap 一起使用,但可以与plotly.express 一起使用吗?

python - 如何使用 Plotly 绘制 3D 条形图/饼图/圆环图

python - 将绘图保存到本地文件并插入到 html