楼主: dxystata
1745 4

[问答] R中直方图 [推广有奖]

版主

已卖:302份资源

大师

37%

还不是VIP/贵宾

-

TA的文库  其他...

Software

中英文Ebook

R学习

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

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

楼主
dxystata 发表于 2014-10-27 12:19:11 |AI写论文
50论坛币
  1. library(ggplot2)
  2. ggplot(diamonds,aes(x=price, fill=color)) +
  3.   geom_histogram(aes(y=..density..)) +
  4.   theme(legend.position="none")


  5. ggplot(diamonds,aes(x=carat, fill=color)) +
  6.   geom_histogram(aes(y =..density..)) +
  7.   theme(legend.position = "none")
复制代码
2014-10-27_102615.jpg   price

2014-10-27_102641.jpg carat


ggplot2 自带数据集diamonds,如何画出一模一样的图?谢谢!


最佳答案

firelife 查看完整内容

不知道要的是什么效果,稍微修改一下代码,类似这样吧 ggplot(diamonds,aes(x=price, fill=color)) + geom_histogram(aes(y=..density..),binwidth=250) + theme(legend.position="none") ggplot(diamonds,aes(x=carat,colour=color)) + geom_histogram(aes(y =..density..),binwidth=0.05,fill="black") + theme(legend.position = "none")
关键词:直方图 histogram diamonds position Diamond 直方图

沙发
firelife 发表于 2014-10-27 12:19:12
不知道要的是什么效果,稍微修改一下代码,类似这样吧

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


ggplot(diamonds,aes(x=carat,colour=color)) +
  geom_histogram(aes(y =..density..),binwidth=0.05,fill="black") +
  theme(legend.position = "none")
已有 1 人评分经验 学术水平 热心指数 收起 理由
dxystata + 50 + 2 + 2 根据规定进行奖励

总评分: 经验 + 50  学术水平 + 2  热心指数 + 2   查看全部评分

藤椅
dxystata 发表于 2014-10-27 13:20:49

板凳
dxystata 发表于 2014-10-28 07:54:33
firelife 发表于 2014-10-27 12:19
不知道要的是什么效果,稍微修改一下代码,类似这样吧

ggplot(diamonds,aes(x=price, fill=color)) +
第一个图如何旋转?谢谢!

报纸
dxystata 发表于 2014-10-28 07:56:50
设置binwidth很重要

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

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