mindlessgreen
mindlessgreen

Reputation: 12142

R plotly: Adjust absolute marker size on 3D scatterplot

I am creating a 3D scatterplot using plotly in R and I would like to reduce the marker size of all points.

library(plotly)
plot_ly(iris,x=~Petal.Width,y=~Sepal.Width,z=~Petal.Length) %>% 
add_markers(color=~Species)

default

I tried to set the sizes argument, but that doesn't seem to change anything.

plot_ly(iris,x=~Petal.Width,y=~Sepal.Width,z=~Petal.Length) %>%
  add_markers(color=~Species,sizes=0.02)

Also tried another argument sizeref. Still, nothing happens.

plot_ly(iris,x=~Petal.Width,y=~Sepal.Width,z=~Petal.Length) %>%
  add_markers(color=~Species,marker=list(sizeref=0.02))

Any other solution to decrease the marker size of all points? Or am I doing something wrong?

Upvotes: 4

Views: 5036

Answers (1)

byouness
byouness

Reputation: 1782

You were close, the argument is size, and marker should go into plot_ly() instead of add_markers().

library(plotly)
plot_ly(iris,x=~Petal.Width,y=~Sepal.Width,z=~Petal.Length,
        marker = list(size = 20)) %>% 
   add_markers(color=~Species)

enter image description here

Upvotes: 5

Related Questions