I would like to hide the markers in a subplot.
Is this possible?
MRE:
import plotly.graph_objs as go
from plotly.subplots import make_subplots
import numpy as np
np.random.seed(42)
n = 100
x, y, z = np.random.rand(3, n)
fig = make_subplots(rows=1, cols=2,
specs=[[{'type': 'scatter'}, {'type': 'scatter'}]]
)
# Scatter plot with markers
fig.add_trace(
go.Scatter(
x=x,
y=y,
mode='lines+markers',
marker=dict(
size=5,
color='red',
opacity=0.8
),
name='m'
),
row=1, col=1)
fig.add_trace(
go.Scatter(
x=x,
y=y,
mode='lines+markers',
marker=dict(
size=5,
color='red',
opacity=0.8
),
name='m2'
), row=1, col=2)
button = dict(
method='restyle',
args=[{"mode": "lines+markers", 'marker.size': 0}],
label='Remove Markers'
)
fig.update_layout(
updatemenus=[{
'buttons': [button],
'direction': 'down',
'showactive': True,
'x': 0.1,
'xanchor': 'left',
'y': 1.1,
'yanchor': 'top'
}]
)
# Show the figure
fig.show()
On my machine, this removes the marker from the legend but not the plot. What am I doing wrong?
How can I remove only the markers on the left subplot and keep the ones on the right subplot?
New contributor
Tpj is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.