yes, sure:
Tkss!
the error is exactly in this part:
PS: I just tried to put a “mode” as well but without success.
add_trace(
x = DATA,
type = "histogram",
name = "",
text = "",
histnorm = "probability",
marker = list(color = 'salmon'),
yaxis = 'y2',
showlegend = FALSE,
xaxis = "x1",
yaxis = "y2",
hoverinfo = "x+y+text",
xbins =
list(
start = DATA.min,
end = DATA.max,
size = (DATA.max - DATA.min)/( 1.5* sqrt(length(DATA)) ) )
) %>%
the entire plot_ly is this:
p<-plot_ly(
x = X,
y = Y,
type = “scatter”,
mode = “markers”,
marker =
list( symbol = c(“star” ,“diamond”),
size = c(15 ,12),
color = c(“darkmagenta” ,“red”)),
opacity = c(1 ,1),
text = c(“mean” ,“last”),
hoverinfo = “x+text”,
showlegend = FALSE,
xaxis = “x1”,
yaxis = “y1”
) %>%
add_trace(
x = rep(DATA.q05,3),
y=seq(-DATA.q05_h,DATA.q05_h,length.out = 3),
text = “q05%”,
line = list(color = “black”),
marker = list(opacity = 0),
hoverinfo = “x+text” ,
showlegend = FALSE,
xaxis = “x1”,
yaxis = “y1”
)%>%
add_trace(
x = rep(DATA.q25,3),
y=seq(-DATA.q25_h,DATA.q25_h,1),
text = “q25%”,
line = list(color = “black”),
marker = list(opacity = 0),
hoverinfo = “x+text” ,
showlegend = FALSE,
xaxis = “x1”,
yaxis = “y1”
) %>%
add_trace(
x = rep(DATA.median,10),
y=seq(-DATA.median_h,DATA.median_h,length.out = 10),
text = “median”,
line = list(color = “darkred”, dash = “dot”),
marker = list(opacity = 0),
hoverinfo = “x+text” ,
showlegend = FALSE,
xaxis = “x1”,
yaxis = “y1”
) %>%
add_trace(
x = rep(DATA.q75,3),
y=seq(-DATA.q75_h,DATA.q75_h,1),
text = “q75%”,
line = list(color = “black”),
marker = list(opacity = 0),
hoverinfo = “x+text” ,
showlegend = FALSE,
xaxis = “x1”,
yaxis = “y1”
) %>%
add_trace(
x = rep(DATA.q95,3),
y=seq(-DATA.q95_h,DATA.q95_h,length.out = 3),
text = “q95%”,
line = list(color = “black”),
marker = list(opacity = 0),
hoverinfo = “x+text” ,
showlegend = FALSE,
xaxis = “x1”,
yaxis = “y1”
) %>%
add_trace(
x = rep(DATA.min,10),
y = seq(-0.5DATA.min_h,DATA.min_h,length.out = 10),
text = “min”,
line = list(color = “darkblue”, dash = “dot”),
marker = list(opacity = 0),
hoverinfo = “x+text” ,
showlegend = FALSE,
xaxis = “x1”,
yaxis = “y1”
) %>%
add_trace(
x = rep(DATA.max,10),
y = seq(-0.5DATA.max_h,DATA.max_h,length.out = 10),
text = “max”,
line = list(color = “darkblue”, dash = “dot”),
marker = list(opacity = 0),
hoverinfo = “x+text” ,
showlegend = FALSE,
xaxis = “x1”,
yaxis = “y1”
) %>%
add_trace(
x = DATA,
type = “histogram”,
name = “”,
text = “”,
histnorm = “probability”,
marker = list(color = ‘salmon’),
yaxis = ‘y2’,
showlegend = FALSE,
xaxis = “x1”,
yaxis = “y2”,
hoverinfo = “x+y+text”,
xbins =
list(
start = DATA.min,
end = DATA.max,
size = (DATA.max - DATA.min)/( 1.5* sqrt(length(DATA)) ) )
) %>%
layout(
bargap = 0.15,
yaxis=
list(
anchor = ‘x1’,
domain = c(0, 0.4),
title = “”,
zeroline = TRUE ,
showline = FALSE,
showticklabels = FALSE,
showgrid = FALSE
),
yaxis2=
list(
anchor = ‘x1’,
domain = c(0.45, 1.0),
title = “”,
zeroline = FALSE ,
showline = FALSE,
showticklabels = FALSE,
showgrid = FALSE
),
margin = m,
xaxis=
list(
title = “”,
zeroline = FALSE,
showline = TRUE,
tickwidth = 2,
tickmode = “auto”,
nticks = 8
),
shapes = list(
list(
type = ‘rectangle’,
xref = ‘x1’, x0 = DATA.q25, x1 = DATA.q75,
yref = ‘y1’, y0 = -0.8DATA.q25_h , y1 = .8DATA.q25_h ,
fillcolor = ‘rgb(50, 20, 90)’,
line = list(color = ‘rgb(50, 20, 90)’),
opacity = .2
)
),
annotations = my_annotations
)