楼主: dxystata
6637 11

[问答] 50论坛币 ggplot2中直方图的旋转 [推广有奖]

版主

已卖:302份资源

大师

37%

还不是VIP/贵宾

-

TA的文库  其他...

Software

中英文Ebook

R学习

威望
2
论坛币
183395 个
通用积分
15333.1475
学术水平
208 点
热心指数
271 点
信用等级
174 点
经验
298627 点
帖子
5586
精华
1
在线时间
13632 小时
注册时间
2006-6-21
最后登录
2025-12-22

初级学术勋章 初级热心勋章 中级热心勋章 初级信用勋章

楼主
dxystata 发表于 2014-10-28 09:11:12 |AI写论文
1论坛币




library(ggplot2)
ggplot(diamonds,aes(x=price, fill=color)) +
  geom_histogram(aes(y=..density..),binwidth=250) +
  theme(legend.position="none")


如何旋转成上图这样?谢谢!


关键词:ggplot2 gplot 50论坛币 plot 0论坛币 直方图

沙发
fxcfinal 发表于 2014-10-28 11:25:01
把X和Y对调试试

藤椅
h52101019 发表于 2014-10-28 15:38:20





library(ggplot2)
ggplot(diamonds,aes(x=price, fill=color)) +
  geom_histogram(aes(y=..density..),binwidth=250) +
  theme(legend.position="none") + theme(angle = 90)

板凳
h52101019 发表于 2014-10-28 15:39:56
library(ggplot2)
ggplot(diamonds,aes(x=price, fill=color)) +
  geom_histogram(aes(y=..density..),binwidth=250) +
  theme(legend.position="none") + theme(angle = 90)

报纸
dxystata 发表于 2014-10-28 20:47:33
h52101019 发表于 2014-10-28 15:39
library(ggplot2)
ggplot(diamonds,aes(x=price, fill=color)) +
  geom_histogram(aes(y=..density..),b ...
Error in (function (el, elname)  :
  "angle" is not a valid theme element name.

地板
dxystata 发表于 2014-10-28 20:48:59
h52101019 发表于 2014-10-28 15:39
library(ggplot2)
ggplot(diamonds,aes(x=price, fill=color)) +
  geom_histogram(aes(y=..density..),b ...
Error in (function (el, elname)  :
  "angle" is not a valid theme element name.

7
firelife 发表于 2014-10-28 21:45:13
coord_flip()
或者
scale_x_reverse

8
dxystata 发表于 2014-10-28 22:01:38
firelife 发表于 2014-10-28 21:45
coord_flip()
或者
scale_x_reverse
用了这两个,但无法实现一模一样的图。

9
蓝色 发表于 2014-10-28 22:22:25
正的做出来,生产图片,然后旋转一下算了

10
dxystata 发表于 2014-10-28 22:28:50
蓝色 发表于 2014-10-28 22:22
正的做出来,生产图片,然后旋转一下算了
要求必须用R实现

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

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