>I'm not particularly fond of rug plots, either. But until someone
>(maybe me if I can figure out how...) adds density plots to the axes,
>they're a quick and dirty way of seeing density along each axis. When
>they get too dense, I sometimes will sample from the original
>distribution to generate a more legible rugplot....
>
I've lost the origin of this thread, but for adding box plots to each axis
of a scatterplot there is the scatterplot function in the car package, which does other
nice things as well.
Peter
Peter L. Flom, PhD
Statistical Consultant
www DOT peterflomconsulting DOT com
d = data.frame(V1 = rnorm(100),V2 = rnorm(100))
p1 = ggplot()+
layer(
data = d
, mapping = aes(
x = V1
, y = V2
)
, geom = 'point'
)+
scale_x_continuous(
limits = c(min(d$V1),max(d$V1))
)
p2 = ggplot()+
layer(
data = d
, mapping = aes(
x = V1
, y = ..density..
)
, geom = 'line'
, stat = 'density'
)+
scale_x_continuous(
limits = c(min(d$V1),max(d$V1))
)+
opts(
panel.grid.minor = theme_blank()
,panel.grid.major = theme_blank()
,axis.ticks = theme_blank()
,axis.text.y = theme_blank()
,axis.text.x = theme_blank()
,axis.title.y = theme_blank()
,axis.title.x = theme_blank()
)
p3 = ggplot()+
layer(
data = d
, mapping = aes(
x = V2
, y = ..density..
)
, geom = 'line'
, stat = 'density'
)+
scale_x_continuous(
limits = c(min(d$V2),max(d$V2))
)+
opts(
panel.grid.minor = theme_blank()
,panel.grid.major = theme_blank()
,axis.ticks = theme_blank()
,axis.text.y = theme_blank()
,axis.text.x = theme_blank()
,axis.title.y = theme_blank()
,axis.title.x = theme_blank()
)+
coord_flip()
size = .7
print(p1,vp = viewport(width = size , height = size , x = size*.5 , y
= size*.5 ))
print(p2,vp = viewport(width = size , height = 1-size , x = size*.5 ,
y = 1-(1-size)*.5 ))
print(p3,vp = viewport(width = 1-size , height = size , x =
1-(1-size)*.5 , y = size*.5 ))
--
Mike Lawrence
Graduate Student
Department of Psychology
Dalhousie University
Looking to arrange a meeting? Check my public calendar:
http://tr.im/mikes_public_calendar
~ Certainty is folly... I think. ~