Ich habe eine Liste a
mit drei Matrizen und einen Vektor h
mit drei Höhen (jede positive reelle Zahl). Diese Matrizen bilden Dreiecke, dh die Basis des Prismas. Ich möchte die Informationen des Vektors h
hinzufügen, um Prismen zu konstruieren.Plot 3D Prismen mit ggplot2 und plotly
Ich habe eine Funktion zum Zeichnen von Grafiken in 2D (pplot
) erstellt. Wie kann ich die Prismen wie in der folgenden Abbildung darstellen?
pplot
Lassen und ein Spielzeug Problem ein Beispiel sein:
library(ggplot2)
pplot <- function(polygon){
polygon <- lapply(polygon, function(x) {colnames(x) <- NULL; x})
vertex_number = nrow(polygon[[1]])
g = ggplot2::ggplot()
names(polygon) = 1:length(polygon)
k <- plyr::ldply(polygon, function(x) data.frame(x))
g <- ggplot2::ggplot(k, ggplot2::aes(x = X1, y = X2, group = .id)) + ggplot2::geom_polygon(colour = "black", fill = NA)
return(g)
}
a <- list()
b1 <- matrix(rnorm(6), ncol = 2)
b2 <- matrix(rnorm(6), ncol = 2)
b3 <- matrix(rnorm(6), ncol = 2)
a[[1]] <- b1
a[[2]] <- b2
a[[3]] <- b3
h <- c(.3, .5, .1)
#pplot function example
pplot(a)
Grafik gewünschten
Wo die Koordinate a = d
, b = f
, c = e
sind Ecken und alle Informationen in a
.
Bemerkung 1: Die Daten müssen eine Liste enthalten.
Bemerkung 2: Ich habe einen Beitrag in Portugiesisch erstellt, aber niemand hat geantwortet. Kann ich das tun oder es betrügt? (Ich bin neu hier) https://pt.stackoverflow.com/questions/165538/plotar-figuras-3d-para-dados-em-lista
Ich dachte ggplot nicht 3D zu tun haben. Können Sie uns auf ein Beispiel hinweisen, in dem diese Vermutung sich als falsch erwiesen hat? –
Ein Beispiel kann in gesehen werden: https://www.r-bloggers.com/3d-plots-with-ggplot2-and-plotly/ –
Wie ich diesen Blog lese, ist es plotly, dass der 3D-razzmatazz macht. –