how to use a log scale for y-axis of histogram in R?

痞子三分冷 提交于 2019-12-22 17:07:18

问题


I have a large dataset with the lifespan of threads on an discussion board. I want a histogram that shows the distribution of lifespan, so I did this:

dall <- read.csv("lifespan.csv")
colnames(dall) <- c("thread.id", "seconds.alive", "start.time")
hist(dall$seconds.alive)

which generated this hard to read image:

My questions are a) is changing y-axis to a log-scale a good way to make it more readable? Apparently some people think is a bad idea to change y-axis to log.

b) how do I do that?


回答1:


I would try using hist(log10(dall$seconds.alive)) instead.

Also try specifying breaks=100 or smaller/larger number:

hist(log10(dall$seconds.alive), breaks=100)


来源:https://stackoverflow.com/questions/4149214/how-to-use-a-log-scale-for-y-axis-of-histogram-in-r

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!