0
votes

I have a data frame like this:

dput(df)
structure(list(date = structure(c(16476, 16477, 16524, 16541, 
16595, 16658, 16769, 16804, 16819, 16819, 16828, 16833, 16875
), class = "Date"), y = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L)), .Names = c("date", "y"), row.names = c(NA, 
-13L), class = c("tbl_df", "tbl", "data.frame"))

I use plotly R to plot a scatter plot like this:

plot_ly(df, x = date, y = y, mode = 'markers')

The above statement works perfectly fine.

Now, I just want to increase the size of the points in the scatter plot. Trying this messes up the whole plot including the x axis date scale:

plot_ly(df, x = date, y = y, mode = 'markers', size = 10)

Any idea what is going on? My version is:

packageVersion('plotly')
[1] ‘3.5.5’
1
try this plot_ly(df, x = date, y = y, mode = 'markers', marker = list(size = 10))MLavoie
Wow, that is it. That works. Any idea why the other specification does not work, even though it is documented that way?Gopala
actually, my comment was from the documentation :-)MLavoie
Hmmmm...may be I need to look at the 'right' documentation. ?plot_ly says: size A variable name or numeric vector to encode the size of markers.Gopala
Unless, it means I need to supply the size for each marker for as many points as I have.Gopala

1 Answers

0
votes

On the dev github version it works:

packageVersion('plotly')
> '4.5.6.9000'

p1 <- plot_ly(df, x = ~date, y = ~y) %>%
    add_markers()
p2 <- plot_ly(df, x = ~date, y = ~y) %>%
    add_markers(size = 10)
subplot(p1, p2)

enter image description here