I am plotting a 3D chart with three variables, which are date, diffusion, and avg_Entropy. I would like to insert a simple 2D plane horizontally into the scatter plot that will serve as a threshold for diffusion. I have served multiple forums and tutorials for such an implementation, and all I can find is how to insert a regression line which is not really what I want. I would like to be able to, for example, insert a transparent plane through the 100 value for “diffusion” so that any points above this threshold meet the criteria for my experiment. Here is my current code.
plot_ly(color = ~factor(date), showlegend = T) %>%
add_markers(data = tweets, x = ~date, y = ~avg_Entropy, z = ~diffusion) %>%
add_paths(data = tweets, x = ~date, y = ~avg_Entropy, z = ~diffusion)
Thank you very much for the reply raytong. Do I just substitute my "tweets" data frame for the "df" data frame from your example? If that is the case, what values do I insert into the rnorm() functions? Is the "10" just refer to the number of desired rows from the data set?
@jdude48. Because you didn't provide sample data, I generate the sample data by random rnorm function. In your case, the code should be somethings like below.
library(plotly)
planDf <- data.frame(x = rep(range(tweets$date), 2), y = rep(range(tweets$avg_Entropy), each = 2), z = 100)
plot_ly(tweets) %>%
add_markers(x = ~date, y = ~avg_Entropy, z = ~diffusion, color = ~factor(date), showlegend = T) %>%
add_mesh(x = ~x, y = ~y, z = ~z, data = planDf, opacity = 0.3)
raytong, I was altering some of the parameters to tweak the appearance of the plane a little bit. I tried "color" and I tried "colorscale" but neither of those would change the color of the plane. Also, how can I expand the size of the plane a little bit? There are some of my points in the plot that do not intersect with the threshold plane. Thank you.
raytong, I used the mulFactor and played around with the factor numbers and the plane size kept getting smaller and smaller. Here was the code that I used.
mulFactor = 6
planDf <- data.frame(x = rep(range(tweets$date)*mulFactor, 2), y = rep(range(tweets$avg_Entropy)*mulFactor, each = 2), z = 70)
The 2D mesh was tiny when the graph rendered. Should I be creating the factor parameters differently?