[R] funny plotting
Austin, Matt
maustin at amgen.com
Wed Jun 30 07:40:21 CEST 2004
Try something like
plot(x,y)
box.dat <- boxplot(x=split(counts, dial), plot=FALSE)
bxp(box.dat, add=TRUE, at=c(-1, 0, 1), show.names=FALSE)
-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch]On Behalf Of Karla Meurk
Sent: Tuesday, June 29, 2004 21:46 PM
To: R-help at stat.math.ethz.ch
Subject: [R] funny plotting
Hi, I just wanted to plot a boxplot with a nice curve going through it,
I thought this would be a simple task but for some reason I can't get
the two graphs on the same page accurately. Enclosed is the code showing
the two plots seperately and together. I would have thought it should
work if I could use boxplot() then plot() overlayed but it won't allow
the command add=TRUE (which has worked for me in the past).
Thanks
Carla
P.S. please excuse the clumsy code!
#Section 2 Data Set particle
dial<-rbind(-1,
-1,
0,
0,
0,
0,
1,
1,
1)
counts<-rbind(2,
3,
6,
7,
8,
9,
10,
12,
15)
particle<-as.data.frame(cbind(dial,counts),row.names=NULL)
names(particle)<-c("dial","counts")
attach(particle)
pois.particle<-glm(counts~dial,family=poisson)
x<-seq(-2,2,length=20)
y<-predict(pois.particle,data.frame(dial=x),type="response")
#Overlaying plots
x11()
boxplot(counts~dial,main="Boxplot of counts for dial setting and poisson
fit",ylim=c(0,25))
lines(x,y)
#The seperate plots
x11()
boxplot(counts~dial,ylim=c(0,25))
x11()
plot(x,y,ylim=c(0,25),type="l")
______________________________________________
R-help at stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html
More information about the R-help
mailing list