The data formate "NB" is as follows.
> head(NB)
time speed traffic density
1 06:00 44.04854 304.6616 108.4641
2 06:10 43.73164 332.3510 111.6164
3 06:20 43.35056 359.2273 114.8773
4 06:30 42.91960 382.6465 118.5487
5 06:40 42.42904 400.3864 121.8942
6 06:50 41.91823 415.5429 124.9405
> str(NB)
'data.frame': 85 obs. of 4 variables:
$ time : Factor w/ 144 levels "00:00","00:10",..: 37 38 39 40 41 42 43 44 45 46 ...
$ speed : num 44 43.7 43.4 42.9 42.4 ...
$ traffic: num 305 332 359 383 400 ...
$ density: num 108 112 115 119 122 ...
I have used the below code to make a 3d graph. I want to know how to add the first "time" column to the 3d graph plotted dots and label "time"(06:00, 06:10 .... 20:00)
zz <- scatterplot3d(x=NB[,2],y=NB[,3], z=NB[,4],main=naljja,xlab="speed",ylab="traffic",zlab="density",pch=1,color = "blue",grid = TRUE)
Try taking your
zz
object (result ofscatterplot3d
) and use thexyz.convert
function to transform the coordinates from 3D (x, y, z) to a 2D-projection (x, y). Then use can usetext
and add labels to the graph from thetime
column (first column). In this case, I usedcex
to reduce the text size, andpos
to place label to the right of the points.Plot
Data
Reference
https://www.r-bloggers.com/2012/01/getting-fancy-with-3-d-scatterplots/