开发者

Scale y-axis (counts) in ggplot2 histogram

开发者 https://www.devze.com 2023-01-18 16:33 出处:网络
I am plotting a simple histogram of data sampled at, say, 10%.I want counts on the y-axis, but since the data are sampled, I want them to be scaled appropriately.If I were using base graphics, I\'d do

I am plotting a simple histogram of data sampled at, say, 10%. I want counts on the y-axis, but since the data are sampled, I want them to be scaled appropriately. If I were using base graphics, I'd do something like

foo <- rnorm(50)
foo.hist <- hist(foo,plot=F)
foo.hist$counts <- foo.hist$counts * 10
plot(foo.hist)

Is there an easy way to accomplish this with ggplot2?.. There are all sorts of "canned" y-axis transformations (scale_y_log(), etc开发者_如何学运维); is there something more general-purpose?


is this what you are looking for?

df<-data.frame(x=rnorm(50))
ggplot(df,aes(x))+geom_histogram(aes(y=..count..*10))
0

精彩评论

暂无评论...
验证码 换一张
取 消