ackerdwm / gg3d Goto Github PK
View Code? Open in Web Editor NEWA ggplot2 extension enabling 3D projections
A ggplot2 extension enabling 3D projections
Hi,
I've written scripts that uses gg3d (they look beautiful my graphs, thank you very much). However, when I had a collaborator run the scripts and install the packages they ran into some troubles that I can't seem to recreate.
I had a problem with rlang. Others may not have this. gg3D requires rlang,
which it tries to compile from source. There is a package version number
mismatch (it asks for 0.3.1 and the latest on Cran is 0.3.4). This means
the gg3D installation fails at rlang. I had to install and update rlang to
0.3.1, and reinstall gg3D but not update rlang and ggplot. Then it worked.
I updated rlang, ggplot and gg3d and didn't have this problem.
Any ideas of how to best adapt?
Hello and thanks for the excellent package.
Just to let you know that I can't seem to get any alpha option < 1 working for stat_wireframe (stat_3D is fine). Not even with the examples in the vignette. Guess it's something that has changed in ggplot2.
I cannot integrate this with custom images for scatterplot points. This code:
library(ggplot2)
library(ggimage)
library(gg3D)
ggplot(d, aes(x=x, y=y, z=z, color=z)) +
axes_3D() +
geom_image(aes(image=image, color=z)) +
scale_color_gradient(low='burlywood1', high='burlywood4')
Hi and thank you for the package,
I'm having an issue with a wireframe plot.
I'm using your vignette as a guideline:
ggplot(df, aes(Var1, Var2, z=value)) + axes_3D() + stat_wireframe(alpha=.5) + theme_void() + theme(legend.position = "none") + labs_3D(hjust=c(0,1,1), vjust=c(1, 1, -0.2), angle=c(0, 0, 90))
When adapting the code to my case, I write:
ggplot(df, aes(Dim1, Dim2, z = Dim3)) + axes_3D() + stat_wireframe(alpha=.5) + theme_void()
where df
is my dataframe with three columns called "Dim1, Dim2, "Dim3".
However, I obtain the messag
Warning message:
Computation failed in stat_wireframe()
:
object 'x' not found
and an empty 3D space (only the 3 axes)
I don't understand which is the problem. Could you help me?
Thank you
Hi Dan,
I really like the package!
I'm having a hard time figuring out why I'm getting the following error:
Warning messages:
The following aesthetics were dropped during statistical transformation: z, colour
ℹ This can happen when ggplot fails to infer the correct grouping structure in the data.
ℹ Did you forget to specify agroup
aesthetic or to convert a numerical variable into a factor?
I have checked that my group variable is a factor, I have no missing data, and I have specified all three axes:
grh_clusters %>%
dplyr::select(lineage:PC11)%>%
ggplot(aes(x = PC0, y = PC1, z = PC2, color = lineage, group = lineage)) +
stat_3D(theta = theta, phi = phi, geom = "point", size = 6)+
axes_3D(theta = theta, phi = phi) +
scale_color_manual(values = grahami_colors,
breaks = c("East", "Wagwater", "Central", "West"),
guide = "none")+
theme_void()
Here is a sampling of the data I'm inputting:
A tibble: 171 × 13
lineage PC0 PC1 PC2 PC3 PC4 PC5 PC6 PC7 PC8 PC9 PC10 PC11
fct dbl dbl dbl dbl dbl dbl dbl dbl dbl dbl dbl dbl
1 West -15.1 25.7 0.444 0.650 -1.10 8.13 -0.564 -0.353 -0.0913 -2.28 -1.99 9.81
2 West -15.2 26.5 0.696 0.243 -1.27 9.88 -1.50 0.139 1.18 -0.170 -1.37 -3.03
3 West -14.7 26.2 0.515 0.324 -1.16 8.38 -1.19 0.297 0.229 -0.192 0.839 4.07
4 East 45.1 2.45 0.211 -0.974 0.490 -0.855 -4.21 0.0540 -0.247 0.855 0.869 0.743
5 East 45.6 2.71 0.151 -1.02 0.765 -1.23 -6.88 -0.0178 -0.215 -0.642 -0.217 0.281
6 East 45.7 2.77 0.558 -0.866 0.731 -0.632 -4.43 0.246 -0.0177 -1.56 -0.416 -0.897
7 Central -12.1 -19.2 7.87 1.07 0.534 -0.320 0.231 5.54 3.96 3.44 -1.51 2.21
8 Central -11.9 -19.5 8.29 1.13 2.64 0.305 0.0818 9.18 2.71 0.971 -2.88 0.859
9 Central -12.5 -19.5 7.54 -0.665 0.300 -0.00816 -0.0641 7.21 3.12 1.93 -3.53 2.19
10 Central -12.6 -11.5 11.1 -1.24 -6.01 -1.32 0.614 -6.49 0.621 1.74 2.92 4.67
here's the str():
tibble [171 × 13] (S3: tbl_df/tbl/data.frame)
lineage: Factor w/ 4 levels "Central","East",..: 4 4 4 2 2 2 1 1 1 1 ...
PC0 : num [1:171] -15.1 -15.2 -14.7 45.1 45.6 ...
PC1 : num [1:171] 25.7 26.46 26.22 2.45 2.71 ...
PC2 : num [1:171] 0.444 0.696 0.515 0.211 0.151 ...
PC3 : num [1:171] 0.65 0.243 0.324 -0.974 -1.018 ...
PC4 : num [1:171] -1.101 -1.272 -1.156 0.49 0.765 ...
PC5 : num [1:171] 8.126 9.881 8.383 -0.855 -1.228 ...
PC6 : num [1:171] -0.564 -1.499 -1.186 -4.214 -6.882 ...
PC7 : num [1:171] -0.3528 0.1393 0.2966 0.054 -0.0178 ...
PC8 : num [1:171] -0.0913 1.185 0.2288 -0.2467 -0.2154 ...
PC9 : num [1:171] -2.281 -0.17 -0.192 0.855 -0.642 ...
PC10 : num [1:171] -1.994 -1.369 0.839 0.869 -0.217 ...
PC11 : num [1:171] 9.811 -3.031 4.067 0.743 0.281 ...
I would be so very grateful for any troubleshooting advice you might have
Thanks a heap, Inbar
Hi,
Thank you for this package! I may be missing something obvious but why rescale data? It makes it impossible to do some semi-complex operations such as:
library(ggplot2)
library(gg3D)
data(iris)
iris2 <- iris
iris2$Petal.Width <- iris2$Petal.Width + 10
g <- ggplot(iris, aes(x=Petal.Width, y=Sepal.Width, z=Petal.Length, color=Species)) +
theme_void() +
axes_3D() +
stat_3D()
g2 <- g +
stat_3D(aes(x=Petal.Width, y=Sepal.Width, z=Petal.Length, color=Species), iris2)
Here, we expect g
and g2
to be different since g2
has an additional layer with different data but they look just the same.
First of all, awesome package! Thank you for making it! 🥇
The error I got was:
Warning message:
Computation failed in `stat_wireframe()`:
could not find function "arrange"
Installed it from GitHub. Loading dplyr solved the problem.
stat_wireframe.R
should be amended with
#' @importFrom dplyr "arrange"
Hey Dan, thanks for this awesome package, I have been looking for a ggplot-3d-integration for ages. Question: is it possible to draw grid lines using the 3D projection?
Cheers
Jana
Hello, I'm not sure if this is an issue with your package or a factor of how ggplot2 works, but if I plot data in 3-dimensional space, sometimes points that are behind others are plotted in front. I noticed this when I was trying to create a bunch of 3d plots and combine them into a gif. Example code and an output gif are included to show how this results in some really weird behavior. Note how the red points are always behind all the other points.
Thanks for taking the time to create and publish your software!
for(i in 1:360) {
png(paste("gif/Iris", formatC(i, width = 3, flag = "0"), "_3d.png", sep = ""),
width = 1000,
height = 1000,
res = 200)
print(
ggplot(data = iris, aes(x=Petal.Width,
y=Sepal.Width,
z=Petal.Length,
color=Species)) +
axes_3D(theta = 90,
phi = i) +
stat_3D(theta = 90,
phi = i,
size = 8) +
theme_void()
)
dev.off()
}
# run on unix command line:
convert -loop 0 -delay 1 gif/Iris*.png test2.gif
Is there a way to use geom_tile with stat_3D?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.