Home > Mobile >  How to generate a new type of graphics with ggplot2 in R
How to generate a new type of graphics with ggplot2 in R

Time:01-19

If I want to generate a new type of graphics that ggplot2 don’t have, how could I do it. I mean if I want to generate a 3D axes without the grid and just the the axes (like the picture) how can I generate it, I need to use just ggplot2. Can I import some kind of figure, or use a line character of a particular font, or any type of data or extension to import to generate the new graphics ?

In others words why ggplot2 has fancy plots and R base not. Does it use special characters or images to generate the lines ?

Where can I read some issues about it, is just to answer a homework, any lecture o example that let me understand it ?

Thanks and sorry for the question !!!

enter image description here

CodePudding user response:

Try ggplot2 gg3D

If you haven't gg3D - install via devtools::install_github("AckerDWM/gg3D")

I give to you an example, I think, you understand the idea.

qplot(x=1, y=0, z=1, geom="blank")   
theme_void()  
axes_3D()  
geom_segment(aes(x = 0, y = 0.13, xend = 0, yend = 0.5),
               arrow = arrow(length = unit(3, "mm"), type = "closed"), size = 1)  
geom_segment(aes(x = 0, y = 0.135, xend = -0.346, yend = -0.14),
             arrow = arrow(length = unit(3, "mm"), type = "closed"), size = 1)  
geom_segment(aes(x = 0, y = 0.135, xend = 0.346, yend = -0.14),
             arrow = arrow(length = unit(3, "mm"), type = "closed"), size = 1)  
labs_3D(labs=c("z", "x", "y"),
        hjust=c(0,1,-2), vjust=c(1, 1, 0.5), angle=c(0, 0, 0)) 

enter image description here

  •  Tags:  
  • Related