Reputation: 23
I would like to draw arrows between two points. This is the problem, where I made the three arrows with a graphical program to explain my problem.
That is my source code:
require(plotly)
a <- c(5,16,16,17,18,23,25,27,37,42,5)
b <- c(13,12,26,15,14,6,10,22,14,25,17)
c <- c(12,14,25,26,8,9,27,30,31,26.5,12)
ap <- c(5,12,16,17,11,23,25,27,37,21.5,5)
bp <- c(13,12,26,15,14,6,10,22,14,12.5,17)
cp <- c(12,14,25,26,8,9,27,30,31,26,12)
rnn <- c("U1", "U2", "U3", "U4", "U5", "U6", "U7", "U8", "U9", "U10", "U11")
m <- list( symbol = 200, size = 8, line = list( color = toRGB("yellow"), width = 2 ) )
m1 <- list( symbol = "triangle", color="black", sizemod = "diameter", size = 5, line = list( color = "black", width = 2 ) )
plot_ly(x = ap, y = bp, z = cp) %>%
add_trace(marker = m1, type = "scatter3d", mode = "text+markers",
name = "projected", linetypes = NULL, text = rnn) %>%
add_trace(x = a, y = b, z = c, marker = m, type = "scatter3d", mode = "text+markers",
name = "original", linetypes = NULL, text = rnn)
Many thanks.
Upvotes: 2
Views: 3135
Reputation: 9836
Not exactly what you are looking for, but you could try this:
aaa <- c(16, 12)
bbb <- c(12, 12)
ccc <- c(14, 14)
aaaa <- c(18, 11)
bbbb <- c(14, 14)
cccc <- c(8, 8)
aaaaa <- c(42, 21.5)
bbbbb <- c(25, 12.5)
ccccc <- c(26.5, 26)
plot_ly() %>%
add_trace(x = aaa, y = bbb, z = ccc, type = "scatter3d", mode = "lines",
name = "lines", showlegend = FALSE) %>%
add_trace(x = aaaa, y = bbbb, z = cccc, type = "scatter3d", mode = "lines",
name = "lines", showlegend = FALSE) %>%
add_trace(x = aaaaa, y = bbbbb, z = ccccc, type = "scatter3d", mode = "lines",
name = "lines", showlegend = FALSE) %>%
add_trace(x = ap, y = bp, z = cp, marker = m1, type = "scatter3d", mode = "text+markers",
name = "projected", linetypes = NULL, text = rnn) %>%
add_trace(x = a, y = b, z = c, marker = m, type = "scatter3d", mode = "text+markers",
name = "original", linetypes = NULL, text = rnn)
Upvotes: 1