24

I have the following picture, and I want to remove everything besides the dots and the triangle, which means the numbers on the horizontal and vertical axes and the small vertical lines, how can I do it?

Here is the picture:

Triangle

And here is my code:

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

3 Answers 3

32

To turn off the axes:

'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

also if you want to remove the legend:

layout = {
    'showlegend': False,
    ...
Sign up to request clarification or add additional context in comments.

1 Comment

Is there a way to remove the numbers and replace them with categories on yaxis?
26

To turn off axes in newer versions:

fig.update_layout(showlegend=False)
fig.update_xaxes(visible=False)
fig.update_yaxes(visible=False)

Comments

1

Using only a single update_layout call:

fig.update_layout(
    showlegend=False,
    xaxis=dict(visible=False),
    yaxis=dict(visible=False),
)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.