楼主: verbatim
1016 2

[问答] how to have the effect of density from hist() in the filled box in the legend? [推广有奖]

  • 1关注
  • 3粉丝

已卖:25份资源

博士生

5%

还不是VIP/贵宾

-

威望
0
论坛币
513 个
通用积分
2.0505
学术水平
0 点
热心指数
2 点
信用等级
0 点
经验
3404 点
帖子
139
精华
0
在线时间
143 小时
注册时间
2006-12-1
最后登录
2020-1-30

楼主
verbatim 发表于 2014-12-15 08:51:34 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
how to have the effect of density=55 and 45 from hist() in the filled box in the legend? Thanks!

  1. x1 <- rnorm(100)
  2. x2 <- rnorm(100, 2)
  3. hist(x1, main = "", col = "orange",ylab = "density", xlab = "x", freq
  4. = F, density = 55, xlim = c(-2, 5), ylim = c(0, 0.5))
  5. par(new = T)
  6. hist(x2, main = "", col = "green", ylab = "", xlab = "",axes = F, xlim
  7. = c(-2, 5), ylim = c(0, 0.5), density = 45, freq = F)
  8. abline(v = mean(x1), col = "orange", lty = 2, lwd = 2.5)
  9. abline(v = mean(x2), col = "green", lty = 2, lwd = 2.5)
  10. legend(3, 0.45, legend = c("x1", "x2", "mean(x1)", "mean(x2)"),
  11.        col = rep(c("orange", "green"), 2), pch=c(15,15, NA, NA),
  12.        pt.cex=2,
  13.        lty = c(0, 0, 2, 2))
复制代码

二维码

扫码加我 拉你入群

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

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

关键词:Density Effect filled Legend FECT legend filled orange

沙发
DM小菜鸟 发表于 2015-1-19 14:58:54
c("x1", "x2", "mean(x1)", "mean(x2)"
这一句后面再添一对就可以了,如果我理解的没毛病的话...

藤椅
verbatim 发表于 2015-1-20 01:36:26
再添一对什么??

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

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