Skip to content
Prev 174049 / 398502 Next

Way to rotate a histogram?

I actually pasted the wrong code! This attempts to replicate the
original request to replicate a JMP graphic:

library(ggplot2)
test_data<-rnorm(100,mean=10,sd=4)
a = data.frame(obs = test_data,condition = 'None')
p1 = ggplot(
	data = a
	,aes(
		x = obs
	)
)+geom_histogram(
	aes(
		y = ..density..
		)
)+geom_density(
)+scale_x_continuous(
	limits = range(a$obs)
)+opts(
	panel.grid.minor = theme_blank()
	,panel.grid.major = theme_blank()
	,panel.background = theme_rect()
)+coord_flip(
)
p2 = ggplot(
	data = a
	,aes(
		x = condition
		,y = obs
	)
)+geom_boxplot(
)+scale_y_continuous(
	limits = range(a$obs)
)+scale_x_discrete(
	name = ''
	,labels = ''
)+opts(
	panel.grid.minor = theme_blank()
	,panel.grid.major = theme_blank()
	,panel.background = theme_rect()
	,axis.ticks = theme_blank()
	,axis.text.y = theme_blank()
	,axis.title.y = theme_blank()
)
p3 = ggplot(
	data = a
	,aes(
		sample = (obs-mean(obs))/sd(obs)
	)
)+stat_qq(
	distribution=qnorm
)+geom_abline(
	intercept=0
	,slope=1
)+opts(
	panel.grid.minor = theme_blank()
	,panel.grid.major = theme_blank()
	,panel.background = theme_rect()
	,axis.ticks = theme_blank()
	,axis.text.y = theme_blank()
	,axis.title.y = theme_blank()
)
	

print(p1,vp = viewport(width = 1/3,height = 1,x = 1/3*.5,y = .5))
print(p2,vp = viewport(width = 1/3,height = 1,x = 1/3+1/3*.5,y = .5))
print(p3,vp = viewport(width = 1/3,height = 1,x = 2/3+1/3*.5,y = .5))
On Tue, Mar 17, 2009 at 6:36 PM, David Winsemius <dwinsemius at comcast.net> wrote: