[R] Plot_ly bar plots - bars span sevral x values when there are missing values.
Rasmus Liland
jr@| @end|ng |rom po@teo@no
Tue Mar 9 19:57:17 CET 2021
Dear Nevil,
Although I am a bit unfamiliar with
plotly, it seems it is possible to plot
two bars side by side at least:
h <- df[3:4,]
p <- plotly::plot_ly(
data = h,
x = ~ x,
y = ~ y,
type = "bar")
p <- plotly::layout(p=p,
xaxis = list(range = c(0,20)),
title = "example 4 two bars side by side")
plotly::orca(p=p, file="amos4.png")
Thus, if you want to only plot x=3 and
x=11 you need to set y=0 when x=4:10:
h <- df[c(3, 11),]
h <- rbind(h, cbind(x=4:10, y=0))
p <- plotly::plot_ly(
data = h,
x = ~ x,
y = ~ y,
type = "bar")
p <- plotly::layout(p=p,
xaxis = list(range = c(0,20)),
title = "example 2 corrected")
plotly::orca(p=p, file="amos2.png")
I think this has to do with the xaxis
option in plotly::layout there, and not
with the bar width.
Best,
Rasmus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20210309/61ad8b56/attachment.sig>
More information about the R-help
mailing list