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:
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')
Toggling axis labels The axis tick mark labels can be disabled by setting the showticklabels axis property to False . Here is an example of disabling tick labels in all subplots for a faceted figure created using Plotly Express.
Solution. You need to use visible=False inside fig. update_yaxes() or fig.
If I understand you right you want to limit the range of the y-axis itself. You can pass a dict in the keyword argument yaxis . It could be something like go. Layout(yaxis=dict(range=[0, 10])) I hope this helps you.
In this example, we are hiding legend in Plotly with the help of method fig. update(layout_showlegend=False), by passing the showlegend parameter as False.
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,
...
To turn off axes in newer versions:
#legend
fig.update_layout(showlegend=False)
#x axis
fig.update_xaxes(visible=False)
#y axis
fig.update_yaxes(visible=False)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With