if(!require(plotly)) install.packages("plotly")
## Carregando pacotes exigidos: plotly
## Carregando pacotes exigidos: ggplot2
##
## Anexando pacote: 'plotly'
## O seguinte objeto é mascarado por 'package:ggplot2':
##
## last_plot
## O seguinte objeto é mascarado por 'package:stats':
##
## filter
## O seguinte objeto é mascarado por 'package:graphics':
##
## layout
setwd("C:/R/3D")
Data <- read.table("A14.txt", header = TRUE)
Data
## Sample X Y Z A B C Sphericity
## 1 FQA14-27 67 172 -180 62.68 56.52 56.08 0.93
## 2 FQA14-28-1 175 164 -180 53.90 25.72 16.00 0.52
## 3 FQA14-28-2 177 166 -180 47.83 23.11 11.57 0.49
## 4 FQA14-28-3 190 18 -170 59.96 51.03 34.03 0.79
## 5 FQA14-29-1 47 53 -172 52.48 35.07 23.08 0.67
## 6 FQA14-29-2 60 82 -174 38.94 25.73 24.31 0.75
## 7 FQA14-29-3 56 84 -174 37.61 19.28 13.78 0.58
## 8 FQA14-29-4 52 48 -172 69.81 42.70 21.70 0.58
name_column <- "Sphericity"
Data$Valores_Numéricos <- as.numeric(as.character(Data[[name_column]]))
plot3d <- plot_ly(
data = Data,
x = ~X,
y = ~Y,
z = ~Z,
text = ~Sample,
type = "scatter3d",
mode = "markers",
marker = list(
color = ~Sphericity,
colorscale = "Viridis",
size = 7,
opacity = 0.8,
colorbar = list(title = "Sphericity")
),
hoverinfo = "text+x+y+z"
) %>%
layout(
title = "Spatial position of the samples within the excavation unit A14",
scene = list(
xaxis = list(title = "X"),
yaxis = list(title = "Y"),
zaxis = list(title = "Z")
),
hoverlabel = list(bgcolor = "white", font = list(size = 12))
)
plot3d