楼主: wanlin000
3010 1

[问答] 怎么让直方图旋转方向向右 [推广有奖]

  • 0关注
  • 1粉丝

已卖:339份资源

博士生

24%

还不是VIP/贵宾

-

威望
0
论坛币
1013 个
通用积分
0.6000
学术水平
1 点
热心指数
2 点
信用等级
0 点
经验
5678 点
帖子
286
精华
0
在线时间
155 小时
注册时间
2009-9-4
最后登录
2018-7-9

楼主
wanlin000 发表于 2015-11-26 14:54:52 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
为了使用layout 然后在Y坐标上添加个频率图,怎么样实现呢??
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:直方图 Layout You Out Lay layout 直方图

靠自己

沙发
neuroexplorer 发表于 2015-11-29 06:32:40
library(ggplot2)
library(gridExtra)

data1 <- diamonds
detrend <- lm(log(price)~log(carat) ,data=data1)
data1$lprice2 <- resid(detrend)

empty <- ggplot()
empty <- empty + geom_point(aes(1,1), colour="white")
empty <- empty + theme(axis.ticks=element_blank(),
                       panel.background=element_blank(),
                       axis.text.x=element_blank(),
                       axis.text.y=element_blank(),           
                       axis.title.x=element_blank(),
                       axis.title.y=element_blank(),
                       panel.grid=element_blank())

scatter <- qplot(log(carat), lprice2, data=data1,
                 xlab="Weight", ylab="Price Residuals",
                 colour=factor(color),
                 main="Diamonds - Weight to Price by Color")
scatter <- scatter + theme(legend.position="top")
scatter <- scatter + theme(plot.title=element_text(size=20, colour="blue"))

hist_left <- ggplot(data1,aes(x=price, fill=color))
hist_left <- hist_left + geom_histogram(aes(y = ..density..))
hist_left <- hist_left + labs(x=NULL, y=NULL, title=NULL)
hist_left <- hist_left + theme(legend.position = "none")

hist_bottom <- ggplot(data1, aes(x=carat, fill=color))
hist_bottom <- hist_bottom + geom_histogram()
hist_bottom <- hist_bottom + theme(legend.position = "none")

grid.arrange(arrangeGrob(hist_left + coord_flip(), scatter, ncol=2, widths=c(1,3)),
             arrangeGrob(empty, hist_bottom, ncol=2, widths=c(1,3)),
             heights=c(3,1))

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-31 00:03