我在一个ggplotly图例上有一个麻烦的条目,我正试图隐藏它。特定系列的角色对于图表的显示是必要的,但为了让用户有效地使用图表,它确实需要隐藏。
我的代码是:
plotly::ggplotly(z) %>% config(displayModeBar = F) %>% layout(showlegend = TRUE, legend = list(itemclick = FALSE,itemdoubleclick = FALSE,
groupclick = FALSE)) %>% if(trace['fills'] == "NA") {trace['showlegend'] = FALSE}
正如你所看到的,我正试图将其转化为一种状态,但不幸的是,它带来了一个问题:
DPUT:
structure(list(x=structure(list(data=list(list(x=c(0.5,
0.5,1.5,1.5,0.5),y=c(2.5,3.5,3.5,2.5,2.5),text="dow:1<br/>y:3<br/>fills:Activity",
type="scatter",mode="lines",line=list(width=1.88976377952756,
color="rgba(196,201,207,1)",dash="solid"),fill="toself",
fillcolor="rgba(255,115,0,1)",hoveron="fills",name="Activity",
legendgroup="Activity",showlegend=TRUE,xaxis="x",
yaxis="y",hoverinfo="text"),list(x=c(0.5,0.5,1.5,
1.5,0.5),y=c(3.5,4.5,4.5,3.5,3.5),text="dow:1<br/>y:4<br/>fills:Activity",
type="scatter",mode="lines",line=list(width=1.88976377952756,
color="rgba(196,201,207,1)",dash="solid"),fill="toself",
fillcolor="rgba(255,115,0,1)",hoveron="fills",name="Activity",
legendgroup="Activity",showlegend=FALSE,xaxis="x",
yaxis="y",hoverinfo="text"),list(x=c(0.5,0.5,1.5,
1.5,0.5),y=c(4.5,5.5,5.5,4.5,4.5),text="dow:1<br/>y:5<br/>fills:Activity",
type="scatter",mode="lines",line=list(width=1.88976377952756,
color="rgba(196,201,207,1)",dash="solid"),fill="toself",
fillcolor="rgba(255,115,0,1)",hoveron="fills",name="Activity",
legendgroup="Activity",showlegend=FALSE,xaxis="x",
yaxis="y",hoverinfo="text"),list(x=c(1.5,1.5,2.5,
2.5,1.5),y=c(2.5,3.5,3.5,2.5,2.5),text="dow:2<br/>y:3<br/>fills:Activity",
type="scatter",mode="lines",line=list(width=1.88976377952756,
color="rgba(196,201,207,1)",dash="solid"),fill="toself",
fillcolor="rgba(255,115,0,1)",hoveron="fills",name="Activity",
legendgroup="Activity",showlegend=FALSE,xaxis="x",
yaxis="y",hoverinfo="text"),list(x=c(1.5,1.5,2.5,
2.5,1.5),y=c(3.5,4.5,4.5,3.5,3.5),text="dow:2<br/>y:4<br/>fills:Activity",
type="scatter",mode="lines",line=list(width=1.88976377952756,
color="rgba(196,201,207,1)",dash="solid"),fill="toself",
fillcolor="rgba(255,115,0,1)",hoveron="fills",name="Activity",
legendgroup="Activity",showlegend=FALSE,xaxis="x",
yaxis="y",hoverinfo="text"),list(x=c(1.5,1.5,2.5,
2.5,1.5),y=c(4.5,5.5,5.5,4.5,4.5),text="dow:2<br/>y:5<br/>fills:Activity",
type="scatter",mode="lines",line=list(width=1.88976377952756,
color="rgba(196,201,207,1)",dash="solid"),fill="toself",
fillcolor="rgba(255,115,0,1)",hoveron="fills",name="Activity",
legendgroup="Activity",showlegend=FALSE,xaxis="x",
yaxis="y",hoverinfo="text"),list(x=c(-0.5,-0.5,
0.5,0.5,-0.5),y=c(0.5,1.5,1.5,0.5,0.5),text="dow:0<br/>y:1<br/>fills:NA",
type="scatter",mode="lines",line=list(width=1.88976377952756,
color="rgba(196,201,207,1)",dash="solid"),fill="toself",
fillcolor=c("transparent","transparent","transparent",
"transparent","transparent"),hoveron="fills",name="NA",
legendgroup="NA",showlegend=TRUE,xaxis="x",yaxis="y",
hoverinfo="text"),list(x=c(-0.5,-0.5,0.5,0.5,-0.5
),y=c(1.5,2.5,2.5,1.5,1.5),text="dow:0<br/>y:2<br/>fills:NA",
type="scatter",mode="lines",line=list(width=1.88976377952756,
color="rgba(196,201,207,1)",dash="solid"),fill="toself",
fillcolor=c("transparent","transparent","transparent",
"transparent","transparent"),hoveron="fills",name="NA",
legendgroup="NA",showlegend=FALSE,xaxis="x",yaxis="y",
hoverinfo="text"),list(x=c(-0.5,-0.5,0.5,0.5,-0.5
),y=c(2.5,3.5,3.5,2.5,2.5),text="dow:0<br/>y:3<br/>fills:NA",
type="scatter",mode="lines",line=list(width=1.88976377952756,
color="rgba(196,201,207,1)",dash="solid"),fill="toself",
fillcolor=c("transparent","transparent","transparent",
"transparent","transparent"),hoveron="fills",name="NA",
legendgroup="NA",showlegend=FALSE,xaxis="x",yaxis="y",
hoverinfo="text"),list(x=c(-0.5,-0.5,0.5,0.5,-0.5
),y=c(3.5,4.5,4.5,3.5,3.5),text="dow:0<br/>y:4<br/>fills:NA",
type="scatter",mode="lines",line=list(width=1.88976377952756,
color="rgba(196,201,207,1)",dash="solid"),fill="toself",
fillcolor=c("transparent","transparent","transparent",
"transparent","transparent"),hoveron="fills",name="NA",
legendgroup="NA",showlegend=FALSE,xaxis="x",yaxis="y",
hoverinfo="text"),list(x=c(-0.5,-0.5,0.5,0.5,-0.5
),y=c(4.5,5.5,5.5,4.5,4.5),text="dow:0<br/>y:5<br/>fills:NA",
type="scatter",mode="lines",line=list(width=1.88976377952756,
color="rgba(196,201,207,1)",dash="solid"),fill="toself",
fillcolor=c("transparent","transparent","transparent",
"transparent","transparent"),hoveron="fills",name="NA",
legendgroup="NA",showlegend=FALSE,xaxis="x",yaxis="y",
hoverinfo="text"),list(x=c(0.5,0.5,1.5,1.5,0.5),
y=c(1.5,2.5,2.5,1.5,1.5),text="dow:1<br/>y:2<br/>fills:NA",
type="scatter",mode="lines",line=list(width=1.88976377952756,
color="rgba(196,201,207,1)",dash="solid"),fill="toself",
fillcolor=c("transparent","transparent","transparent",
"transparent","transparent"),hoveron="fills",name="NA",
legendgroup="NA",showlegend=FALSE,xaxis="x",yaxis="y",
hoverinfo="text"),list(x=c(1.5,1.5,2.5,2.5,1.5),
y=c(1.5,2.5,2.5,1.5,1.5),text="dow:2<br/>y:2<br/>fills:NA",
type="scatter",mode="lines",line=list(width=1.88976377952756,
color="rgba(196,201,207,1)",dash="solid"),fill="toself",
fillcolor=c("transparent","transparent","transparent",
"transparent","transparent"),hoveron="fills",name="NA",
legendgroup="NA",showlegend=FALSE,xaxis="x",yaxis="y",
hoverinfo="text"),list(x=c(2.5,2.5,3.5,3.5,2.5),
y=c(1.5,2.5,2.5,1.5,1.5),text="dow:3<br/>y:2<br/>fills:NA",
type="scatter",mode="lines",line=list(width=1.88976377952756,
color="rgba(196,201,207,1)",dash="solid"),fill="toself",
fillcolor=c("transparent","transparent","transparent",
"transparent","transparent"),hoveron="fills",name="NA",
legendgroup="NA",showlegend=FALSE,xaxis="x",yaxis="y",
hoverinfo="text"),list(x=c(2.5,2.5,3.5,3.5,2.5),
y=c(2.5,3.5,3.5,2.5,2.5),text="dow:3<br/>y:3<br/>fills:NA",
type="scatter",mode="lines",line=list(width=1.88976377952756,
color="rgba(196,201,207,1)",dash="solid"),fill="toself",
fillcolor=c("transparent","transparent","transparent",
"transparent","transparent"),hoveron="fills",name="NA",
legendgroup="NA",showlegend=FALSE,xaxis="x",yaxis="y",
hoverinfo="text"),list(x=c(2.5,2.5,3.5,3.5,2.5),
y=c(3.5,4.5,4.5,3.5,3.5),text="dow:3<br/>y:4<br/>fills:NA",
type="scatter",mode="lines",line=list(width=1.88976377952756,
color="rgba(196,201,207,1)",dash="solid"),fill="toself",
fillcolor=c("transparent","transparent","transparent",
"transparent","transparent"),hoveron="fills",name="NA",
legendgroup="NA",showlegend=FALSE,xaxis="x",yaxis="y",
hoverinfo="text"),list(x=c(2.5,2.5,3.5,3.5,2.5),
y=c(4.5,5.5,5.5,4.5,4.5),text="dow:3<br/>y:5<br/>fills:NA",
type="scatter",mode="lines",line=list(width=1.88976377952756,
color="rgba(196,201,207,1)",dash="solid"),fill="toself",
fillcolor=c("transparent","transparent","transparent",
"transparent","transparent"),hoveron="fills",name="NA",
legendgroup="NA",showlegend=FALSE,xaxis="x",yaxis="y",
hoverinfo="text"),list(x=c(3.5,3.5,4.5,4.5,3.5),
y=c(1.5,2.5,2.5,1.5,1.5),text="dow:4<br/>y:2<br/>fills:NA",
type="scatter",mode="lines",line=list(width=1.88976377952756,
color="rgba(196,201,207,1)",dash="solid"),fill="toself",
fillcolor=c("transparent","transparent","transparent",
"transparent","transparent"),hoveron="fills",name="NA",
legendgroup="NA",showlegend=FALSE,xaxis="x",yaxis="y",
hoverinfo="text"),list(x=c(3.5,3.5,4.5,4.5,3.5),
y=c(2.5,3.5,3.5,2.5,2.5),text="dow:4<br/>y:3<br/>fills:NA",
type="scatter",mode="lines",line=list(width=1.88976377952756,
color="rgba(196,201,207,1)",dash="solid"),fill="toself",
fillcolor=c("transparent","transparent","transparent",
"transparent","transparent"),hoveron="fills",name="NA",
legendgroup="NA",showlegend=FALSE,xaxis="x",yaxis="y",
hoverinfo="text"),list(x=c(3.5,3.5,4.5,4.5,3.5),
y=c(3.5,4.5,4.5,3.5,3.5),text="dow:4<br/>y:4<br/>fills:NA",
type="scatter",mode="lines",line=list(width=1.88976377952756,
color="rgba(196,201,207,1)",dash="solid"),fill="toself",
fillcolor=c("transparent","transparent","transparent",
"transparent","transparent"),hoveron="fills",name="NA",
legendgroup="NA",showlegend=FALSE,xaxis="x",yaxis="y",
hoverinfo="text"),list(x=c(3.5,3.5,4.5,4.5,3.5),
y=c(4.5,5.5,5.5,4.5,4.5),text="dow:4<br/>y:5<br/>fills:NA",
type="scatter",mode="lines",line=list(width=1.88976377952756,
color="rgba(196,201,207,1)",dash="solid"),fill="toself",
fillcolor=c("transparent","transparent","transparent",
"transparent","transparent"),hoveron="fills",name="NA",
legendgroup="NA",showlegend=FALSE,xaxis="x",yaxis="y",
hoverinfo="text"),list(x=c(4.5,4.5,5.5,5.5,4.5),
y=c(1.5,2.5,2.5,1.5,1.5),text="dow:5<br/>y:2<br/>fills:NA",
type="scatter",mode="lines",line=list(width=1.88976377952756,
color="rgba(196,201,207,1)",dash="solid"),fill="toself",
fillcolor=c("transparent","transparent","transparent",
"transparent","transparent"),hoveron="fills",name="NA",
legendgroup="NA",showlegend=FALSE,xaxis="x",yaxis="y",
hoverinfo="text"),list(x=c(4.5,4.5,5.5,5.5,4.5),
y=c(2.5,3.5,3.5,2.5,2.5),text="dow:5<br/>y:3<br/>fills:NA",
type="scatter",mode="lines",line=list(width=1.88976377952756,
color="rgba(196,201,207,1)",dash="solid"),fill="toself",
fillcolor=c("transparent","transparent","transparent",
"transparent","transparent"),hoveron="fills",name="NA",
legendgroup="NA",showlegend=FALSE,xaxis="x",yaxis="y",
hoverinfo="text"),list(x=c(4.5,4.5,5.5,5.5,4.5),
y=c(3.5,4.5,4.5,3.5,3.5),text="dow:5<br/>y:4<br/>fills:NA",
type="scatter",mode="lines",line=list(width=1.88976377952756,
color="rgba(196,201,207,1)",dash="solid"),fill="toself",
fillcolor=c("transparent","transparent","transparent",
"transparent","transparent"),hoveron="fills",name="NA",
legendgroup="NA",showlegend=FALSE,xaxis="x",yaxis="y",
hoverinfo="text"),list(x=c(4.5,4.5,5.5,5.5,4.5),
y=c(4.5,5.5,5.5,4.5,4.5),text="dow:5<br/>y:5<br/>fills:NA",
type="scatter",mode="lines",line=list(width=1.88976377952756,
color="rgba(196,201,207,1)",dash="solid"),fill="toself",
fillcolor=c("transparent","transparent","transparent",
"transparent","transparent"),hoveron="fills",name="NA",
legendgroup="NA",showlegend=FALSE,xaxis="x",yaxis="y",
hoverinfo="text"),list(x=c(4.5,4.5,5.5,5.5,4.5),
y=c(5.5,6.5,6.5,5.5,5.5),text="dow:5<br/>y:6<br/>fills:NA",
type="scatter",mode="lines",line=list(width=1.88976377952756,
color="rgba(196,201,207,1)",dash="solid"),fill="toself",
fillcolor=c("transparent","transparent","transparent",
"transparent","transparent"),hoveron="fills",name="NA",
legendgroup="NA",showlegend=FALSE,xaxis="x",yaxis="y",
hoverinfo="text"),list(x=c(5.5,5.5,6.5,6.5,5.5),
y=c(1.5,2.5,2.5,1.5,1.5),text="dow:6<br/>y:2<br/>fills:NA",
type="scatter",mode="lines",line=list(width=1.88976377952756,
color="rgba(196,201,207,1)",dash="solid"),fill="toself",
fillcolor=c("transparent","transparent","transparent",
"transparent","transparent"),hoveron="fills",name="NA",
legendgroup="NA",showlegend=FALSE,xaxis="x",yaxis="y",
hoverinfo="text"),list(x=c(5.5,5.5,6.5,6.5,5.5),
y=c(2.5,3.5,3.5,2.5,2.5),text="dow:6<br/>y:3<br/>fills:NA",
type="scatter",mode="lines",line=list(width=1.88976377952756,
color="rgba(196,201,207,1)",dash="solid"),fill="toself",
fillcolor=c("transparent","transparent","transparent",
"transparent","transparent"),hoveron="fills",name="NA",
legendgroup="NA",showlegend=FALSE,xaxis="x",yaxis="y",
hoverinfo="text"),list(x=c(5.5,5.5,6.5,6.5,5.5),
y=c(3.5,4.5,4.5,3.5,3.5),text="dow:6<br/>y:4<br/>fills:NA",
type="scatter",mode="lines",line=list(width=1.88976377952756,
color="rgba(196,201,207,1)",dash="solid"),fill="toself",
fillcolor=c("transparent","transparent","transparent",
"transparent","transparent"),hoveron="fills",name="NA",
legendgroup="NA",showlegend=FALSE,xaxis="x",yaxis="y",
hoverinfo="text"),list(x=c(5.5,5.5,6.5,6.5,5.5),
y=c(4.5,5.5,5.5,4.5,4.5),text="dow:6<br/>y:5<br/>fills:NA",
type="scatter",mode="lines",line=list(width=1.88976377952756,
color="rgba(196,201,207,1)",dash="solid"),fill="toself",
fillcolor=c("transparent","transparent","transparent",
"transparent","transparent"),hoveron="fills",name="NA",
legendgroup="NA",showlegend=FALSE,xaxis="x",yaxis="y",
hoverinfo="text"),list(x=c(5.5,5.5,6.5,6.5,5.5),
y=c(5.5,6.5,6.5,5.5,5.5),text="dow:6<br/>y:6<br/>fills:NA",
type="scatter",mode="lines",line=list(width=1.88976377952756,
color="rgba(196,201,207,1)",dash="solid"),fill="toself",
fillcolor=c("transparent","transparent","transparent",
"transparent","transparent"),hoveron="fills",name="NA",
legendgroup="NA",showlegend=FALSE,xaxis="x",yaxis="y",
hoverinfo="text"),list(x=c(0,1,2,3,4,5,6),y=c(6.75,
6.75,6.75,6.75,6.75,6.75,6.75),text=c("M","T","W",
"T","F","S","S"),hovertext=c("pos.x:0<br/>pos.y:6.75<br/>week:M",
"pos.x:1<br/>pos.y:6.75<br/>week:T","pos.x:2<br/>pos.y:6.75<br/>week:W",
"pos.x:3<br/>pos.y:6.75<br/>week:T","pos.x:4<br/>pos.y:6.75<br/>week:F",
"pos.x:5<br/>pos.y:6.75<br/>week:S","pos.x:6<br/>pos.y:6.75<br/>week:S"
),textfont=list(size=17.007874015748,color="rgba(196,201,207,1)"),
type="scatter",mode="text",hoveron="points",showlegend=FALSE,
xaxis="x",yaxis="y",hoverinfo="text",name=""),
list(x=c(5,6,0,1,2,3,4,5,6,0,1,2,3,4,5,6,
0,1,2,3,4,5,6,0,1,2,3,4,5,6,0),y=c(6,6,
5,5,5,5,5,5,5,4,4,4,4,4,4,4,3,3,3,3,3,
3,3,2,2,2,2,2,2,2,1),text=c("","","","Run",
"Run","","","","","","Run",
"Run","","","","","","Run",
"Run","","","","","","","","",
"","","",""),hovertext=c("dow:5<br/>y:6<br/>texts:",
"dow:6<br/>y:6<br/>texts:","dow:0<br/>y:5<br/>texts:",
"dow:1<br/>y:5<br/>texts:Run","dow:2<br/>y:5<br/>texts:Run",
"dow:3<br/>y:5<br/>texts:","dow:4<br/>y:5<br/>texts:",
"dow:5<br/>y:5<br/>texts:","dow:6<br/>y:5<br/>texts:",
"dow:0<br/>y:4<br/>texts:","dow:1<br/>y:4<br/>texts:Run",
"dow:2<br/>y:4<br/>texts:Run",
"dow:3<br/>y:4<br/>texts:","dow:4<br/>y:4<br/>texts:",
"dow:5<br/>y:4<br/>texts:","dow:6<br/>y:4<br/>texts:",
"dow:0<br/>y:3<br/>texts:","dow:1<br/>y:3<br/>texts:Run",
"dow:2<br/>y:3<br/>texts:Run","dow:3<br/>y:3<br/>texts:",
"dow:4<br/>y:3<br/>texts:","dow:5<br/>y:3<br/>texts:",
"dow:6<br/>y:3<br/>texts:","dow:0<br/>y:2<br/>texts:",
"dow:1<br/>y:2<br/>texts:","dow:2<br/>y:2<br/>texts:",
"dow:3<br/>y:2<br/>texts:","dow:4<br/>y:2<br/>texts:",
"dow:5<br/>y:2<br/>texts:","dow:6<br/>y:2<br/>texts:",
"dow:0<br/>y:1<br/>texts:"),textfont=list(size=7.21889763779528,
color="rgba(0,0,0,1)"),type="scatter",mode="text",
hoveron="points",showlegend=FALSE,xaxis="x",
yaxis="y",hoverinfo="text",name=""),list(x=c(4.6,
5.6,-0.4,0.6,1.6,2.6,3.6,4.6,5.6,-0.4,0.6,1.6,
2.6,3.6,4.6,5.6,-0.4,0.6,1.6,2.6,3.6,4.6,5.6,-0.4,
0.6,1.6,2.6,3.6,4.6,5.6,-0.4),y=c(6.35,6.35,5.35,
5.35,5.35,5.35,5.35,5.35,5.35,4.35,4.35,4.35,4.35,
4.35,4.35,4.35,3.35,3.35,3.35,3.35,3.35,3.35,3.35,
2.35,2.35,2.35,2.35,2.35,2.35,2.35,1.35),text=1:31,
hovertext=c("dow-0.4:4.6<br/>y+0.35:6.35<br/>1:nrow(filler):1",
"dow-0.4:5.6<br/>y+0.35:6.35<br/>1:nrow(filler):2",
"dow-0.4:-0.4<br/>y+0.35:5.35<br/>1:nrow(filler):3",
"dow-0.4:0.6<br/>y+0.35:5.35<br/>1:nrow(filler):4",
"dow-0.4:1.6<br/>y+0.35:5.35<br/>1:nrow(filler):5",
"dow-0.4:2.6<br/>y+0.35:5.35<br/>1:nrow(filler):6",
"dow-0.4:3.6<br/>y+0.35:5.35<br/>1:nrow(filler):7",
"dow-0.4:4.6<br/>y+0.35:5.35<br/>1:nrow(filler):8",
"dow-0.4:5.6<br/>y+0.35:5.35<br/>1:nrow(filler):9",
"dow-0.4:-0.4<br/>y+0.35:4.35<br/>1:nrow(filler):10",
"dow-0.4:0.6<br/>y+0.35:4.35<br/>1:nrow(filler):11",
"dow-0.4:1.6<br/>y+0.35:4.35<br/>1:nrow(filler):12",
"dow-0.4:2.6<br/>y+0.35:4.35<br/>1:nrow(filler):13",
"dow-0.4:3.6<br/>y+0.35:4.35<br/>1:nrow(filler):14",
"dow-0.4:4.6<br/>y+0.35:4.35<br/>1:nrow(filler):15",
"dow-0.4:5.6<br/>y+0.35:4.35<br/>1:nrow(filler):16",
"dow-0.4:-0.4<br/>y+0.35:3.35<br/>1:nrow(filler):17",
"dow-0.4:0.6<br/>y+0.35:3.35<br/>1:nrow(filler):18",
"dow-0.4:1.6<br/>y+0.35:3.35<br/>1:nrow(filler):19",
"dow-0.4:2.6<br/>y+0.35:3.35<br/>1:nrow(filler):20",
"dow-0.4:3.6<br/>y+0.35:3.35<br/>1:nrow(filler):21",
"dow-0.4:4.6<br/>y+0.35:3.35<br/>1:nrow(filler):22",
"dow-0.4:5.6<br/>y+0.35:3.35<br/>1:nrow(filler):23",
"dow-0.4:-0.4<br/>y+0.35:2.35<br/>1:nrow(filler):24",
"dow-0.4:0.6<br/>y+0.35:2.35<br/>1:nrow(filler):25",
"dow-0.4:1.6<br/>y+0.35:2.35<br/>1:nrow(filler):26",
"dow-0.4:2.6<br/>y+0.35:2.35<br/>1:nrow(filler):27",
"dow-0.4:3.6<br/>y+0.35:2.35<br/>1:nrow(filler):28",
"dow-0.4:4.6<br/>y+0.35:2.35<br/>1:nrow(filler):29",
"dow-0.4:5.6<br/>y+0.35:2.35<br/>1:nrow(filler):30",
"dow-0.4:-0.4<br/>y+0.35:1.35<br/>1:nrow(filler):31"
),textfont=list(size=11.3385826771654,color="rgba(196,201,207,1)"),
type="scatter",mode="text",hoveron="points",
showlegend=FALSE,xaxis="x",yaxis="y",hoverinfo="text",
name="")),layout=list(margin=list(t=80.3623158562216,
r=18.8976377952756,b=41.4482436270808,l=22.5506058318053),
plot_bgcolor="transparent",paper_bgcolor="rgba(18,39,63,1)",
font=list(color="rgba(0,0,0,1)",family="arial",size=14.6118721461187),
title=list(text="<b>October2022</b>",
font=list(color="rgba(196,201,207,1)",family="arial",
size=26.5670402656704),x=0.5,xref="paper"),
xaxis=list(type="linear",autorange=FALSE,range=c(-0.85,
6.85),tickmode="array",ticktext=c("0","2","4","6"
),tickvals=c(0,2,4,6),categoryorder="array",categoryarray=c("0",
"2","4","6"),nticks=NA,ticks="",tickcolor=NA,
ticklen=3.65296803652968,tickwidth=0,showticklabels=FALSE,
tickfont=list(color=NA,family=NA,size=0),tickangle=0,
showline=FALSE,linecolor=NA,linewidth=0,showgrid=TRUE,
domain=c(0,1),gridcolor="rgba(18,39,63,1)",gridwidth=0.66417600664176,
zeroline=FALSE,anchor="y",title=list(text="",
font=list(color=NA,family=NA,size=0)),
hoverformat=".2f"),yaxis=list(type="linear",autorange=FALSE,
range=c(0.1375,7.1125),tickmode="array",ticktext=c("2",
"4","6"),tickvals=c(2,4,6),categoryorder="array",
categoryarray=c("2","4","6"),nticks=NA,ticks="",
tickcolor=NA,ticklen=3.65296803652968,tickwidth=0,
showticklabels=FALSE,tickfont=list(color=NA,family=NA,
size=0),tickangle=0,showline=FALSE,linecolor=NA,
linewidth=0,showgrid=TRUE,domain=c(0,1),gridcolor="rgba(18,39,63,1)",
gridwidth=0.66417600664176,zeroline=FALSE,anchor="x",
title=list(text="",font=list(color=NA,family=NA,
size=0)),hoverformat=".2f"),shapes=list(list(
type="rect",fillcolor=NA,line=list(color=NA,
width=0,linetype=character(0)),yref="paper",
xref="paper",x0=0,x1=1,y0=0,y1=1)),showlegend=FALSE,
legend=list(bgcolor="rgba(255,255,255,1)",bordercolor="transparent",
borderwidth=1.88976377952756,font=list(color="rgba(0,0,0,1)",
family="arial",size=11.689497716895)),hovermode="closest",
barmode="relative"),config=list(doubleClick="reset",
modeBarButtonsToAdd=c("hoverclosest","hovercompare"),
showSendToCloud=FALSE,displayModeBar=FALSE),source="A",
attrs=list(`1c48494a2361`=structure(list(x=~~dow,y=~~y,
fill=~~fills,type="scatter"),class="plotly_eval"),
`1c48cc46065`=structure(list(x=~~pos.x,y=~~pos.y,
label=~~week),class="plotly_eval"),`1c4824ce4e07`=structure(list(
x=~~dow,y=~~y,label=~~texts),class="plotly_eval"),
`1c48447b47b4`=structure(list(x=~~dow-0.4,y=~~y+
0.35,label=~~1:nrow(filler)),class="plotly_eval")),
cur_data="1c48494a2361",visdat=list(`1c48494a2361`=function(y)
x,`1c48cc46065`=function(y)
x,`1c4824ce4e07`=function(y)
x,`1c48447b47b4`=function(y)
x),layoutAttrs=list(`1c48494a2361`=list(showlegend=TRUE,
legend=list(itemclick=FALSE,itemdoubleclick=FALSE,
groupclick=FALSE)))),TOJSON_FUNC=function(x,
...)
{
jsonlite::toJSON(x,digits=50,auto_unbox=TRUE,force=TRUE,
null="null",na="null",time_format="%Y-%m-%d%H:%M:%OS6",
...)
}),width=NULL,height=NULL,sizingPolicy=list(defaultWidth="100%",
defaultHeight=400,padding=0,viewer=list(defaultWidth=NULL,
defaultHeight=NULL,padding=NULL,fill=TRUE,suppress=FALSE,
paneHeight=NULL),browser=list(defaultWidth=NULL,
defaultHeight=NULL,padding=NULL,fill=TRUE,external=FALSE),
knitr=list(defaultWidth=NULL,defaultHeight=NULL,figure=TRUE)),
dependencies=list(structure(list(name="typedarray",version="0.1",
src=list(file="htmlwidgets/lib/typedarray"),meta=NULL,
script="typedarray.min.js",stylesheet=NULL,head=NULL,
attachment=NULL,package="plotly",all_files=FALSE),class="html_dependency"),
structure(list(name="jquery",version="3.5.1",src=list(
file="lib/jquery"),meta=NULL,script="jquery.min.js",
stylesheet=NULL,head=NULL,attachment=NULL,
package="crosstalk",all_files=TRUE),class="html_dependency"),
structure(list(name="crosstalk",version="1.2.0",
src=list(file="www"),meta=NULL,script="js/crosstalk.min.js",
stylesheet="css/crosstalk.min.css",head=NULL,
attachment=NULL,package="crosstalk",all_files=TRUE),class="html_dependency"),
structure(list(name="plotly-htmlwidgets-css",version="2.5.1",
src=list(file="htmlwidgets/lib/plotlyjs"),meta=NULL,
script=NULL,stylesheet="plotly-htmlwidgets.css",
head=NULL,attachment=NULL,package="plotly",
all_files=FALSE),class="html_dependency"),structure(list(
name="plotly-main",version="2.5.1",src=list(
file="htmlwidgets/lib/plotlyjs"),meta=NULL,
script="plotly-latest.min.js",stylesheet=NULL,
head=NULL,attachment=NULL,package="plotly",
all_files=FALSE),class="html_dependency")),
elementId=NULL,preRenderHook=function(p,registerFrames=TRUE)
{
UseMethod("plotly_build")
},jsHooks=list()),class=c("plotly","htmlwidget"),package="plotly")
由于plot存储为R对象,您可以对其进行探索并设置适当的参数。
例如:
for (i in seq_along(p$x$data))
if (length(p$x$data[[i]]$legendgroup)>0)
if(p$x$data[[i]]$legendgroup =="NA")
p$x$data[[i]]$showlegend <- FALSE
p
如果您共享dput(p)
(为了简洁起见,最好是在数据集的样本上(,可以给出更精确的答案。