更改R中直方图的比例 [英] Change scale of histogram in R

查看:66
本文介绍了更改R中直方图的比例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的直方图只有一个bin.我如何以使其具有更多垃圾箱的方式对其进行转换?

My histogram has only one bin in it. How can I convert it in a way such that it has more bins?

我想将附加图像中的图形2转换为类似于图形1的图形,这样我可以看到更多的bin.

I would like to convert graph 2 in the attached image to something resembling graph 1, such that I see more bins.

在执行 hist(df $ FutureCost,main =多护理费分配",xlab ="Charge($)",breaks ="FD",xlim = c(0,500000)),我能够得到更好的图形.多亏了答复.如何将数字1e + 05、2e + 05等转换为数字100000、200000等

Upon doing hist(df$FutureCost,main="Multicare Distribution of charges", xlab="Charge($)",breaks="FD",xlim=c(0,500000)), I was able to get a better graph. Thanks to the replies. How can I convert the numbers 1e+05, 2e+05 etc to numbers like 100000, 200000 etc.

推荐答案

基于上述注释的完整(但不可重现/可测试)的解决方案,并尝试重现ggplot样式...

A complete (but not reproducible/testable) solution based on the comments above, with some attempt to reproduce the ggplot style ...

opar <- options(scipen=100)
par(bg="gray")       ## set plot background color
hist(df$FutureCost,
     main="Multicare Distribution of charges",
     xlab="Charge($)",
     breaks="FD",
     xlim=c(0,500000),col="black")
grid(col="white") ## plots on top of histogram; re-plot
                  ## histogram if you like ...
par(opar) ## restore original settings 

这篇关于更改R中直方图的比例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆