r - Embedding output from ggplot into another plot -


i trying plot scatterplot , box plot of 2 continuous varaibles getting error says,

warning message: in par(fig = c(0, 0.8, 0.55, 1), new = true) : calling par(new=true) no plot

the code worked when replaced lines 4-6 of code with:

plot(mydata$gre, mydata$gpa, xlab="gre",ylab="gpa") 

here's code:

mydata <- read.csv("http://www.ats.ucla.edu/stat/data/binary.csv") par(fig=c(0,0.8,0,0.8), new=true) #plot(mydata$gre, mydata$gpa, xlab="gre",ylab="gpa") d<-ggplot(mydata,aes(x=mydata$gre, y=mydata$gpa)) d<-d+geom_line() d par(fig=c(0,0.8,0.55,1), new=true) boxplot(mydata$gre, horizontal=true, axes=false) par(fig=c(0.65,1,0,0.8),new=true) boxplot(mydata$gpa, axes=false) mtext("enhanced scatterplot", side=3, outer=true, line=-3) 

could please shed light on doing wrong regards ggplot since r isn't recognizing it? what's weird when type d, name of ggplot, plot...

you attempting combine grid plots (ggplot2) , base plots (boxplot), 2 types of plotting not play nicely (hence cryptic warning).

the simplest solution use 1 of grid or base plots replacing call ggplot call plot or other functions (base option) or using grid based functions boxplots (lattice package uses grid) use functions grid package arrange multiple plots.

if want combine grid , base plots can use gridbase package, going require understanding both types of graphics quite well.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -