Plotlyから軸と数字を削除する方法 質問する

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

ベストアンサー1

軸をオフにするには:

'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,
    ...

おすすめ記事