我想使用一个滑块来控制用plotly创建的多个子图。我在Python中找到了以下两个答案:
- Plot.ly. Using slider control with multiple plots
- https://community.plot.ly/t/using-one-slider-to-control-multiple-subplots-not-multiple-traces/13955/4
示例(第二个链接):
import plotly.graph_objs as go
from plotly.tools import make_subplots
fig = make_subplots(1,2)
fig.add_scatter(y=[1,3,2],row=1,col=1,visible=True)
fig.add_scatter(y=[3,1,1.5],visible='legendonly')
fig.add_scatter(y=[2,2,1],visible='legendonly')
fig.add_scatter(y=[1,col=2,visible=True)
fig.add_scatter(y=[1.5,2.5],visible='legendonly')
fig.add_scatter(y=[2.5,1.2,2.9],visible='legendonly')
steps = []
for i in range(3):
step = dict(
method = 'restyle',args = ['visible',['legendonly'] * len(fig.data)],)
step['args'][1][i] = True
step['args'][1][i+3] = True
steps.append(step)
sliders = [dict(
steps = steps,)]
fig.layout.sliders = sliders
go.FigureWidget(fig)
但是我如何在R中实现呢?