1

Plotting 3d line graph using 'scatterplot3d' in R. Is there a way to display the colours discreetly instead of them blending in together by default?

I've looked everywhere in the documentation but couldn't find anything that would allow the colours to be displayed discreetly (i.e. one month = its colour specified in the data frame). Here is what I have at the moment:

months <- c("June", "July", "August", "September")
trees <- c("birch", "birch", "birch", "birch")
height <- c("10", "12", "14", "20")
colour <- c("#7F7F7F", "#E36C09", "#FFFF00", "#E36C09")

forest <- data.frame(trees, months, height, colour)
plot_ly(data = forest, x = ~months, y = ~height, z= ~trees, split = ~trees,
                       type = 'scatter3d', mode = 'lines', 
                       line = list(color = forest$colour, width = 10)) %>%
layout(
title = "tree height",      
scene = list(
  xaxis = list(title = " ", dtick = 1),    
  yaxis = list(title = "height, cm"),     
  zaxis = list(title = " ")
))

M--
  • 25,431
  • 8
  • 61
  • 93
kpv
  • 35
  • 6
  • You have four colors for the points in your dataframe. you can see them as a gradient or draw points and set the color of them. What exactly do you except to see? – M-- Jul 23 '19 at 21:29
  • I'd suggested points to the person who asked for this graph, but they want lines. What I'd like, ideally, is for the colours not to blend with each other at all - so that orange is abruptly interrupted by yellow etc. – kpv Jul 23 '19 at 21:37
  • OK. Abruptly where? you want orange mid august then yellow between mid august and mid july? you gotta have a clear limit for each color!!! Tell us the limits for each color. – M-- Jul 24 '19 at 14:19
  • Yes sorry! If each month is a point, I'd like it to end just between the two months. As in, in the output example the yellow for August will be from the midpoint between September and August, and to the midpoint between August and July. Same goes for other months. Obviously, at the end of the grid it will only be a half of that coloured line. Is that possible to do at all? – kpv Jul 25 '19 at 12:19

0 Answers0