使用R使直方图中的y轴对数 [英] Make y-axis logarithmic in histogram using R

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

问题描述

我正在使用R制作直方图,但是Y轴的数量太大,我需要将其转换为对数.请参见下面的脚本:

Hi I'm making histogram using R, but the number of Y axis is so large that I need to turn it into logarithmic.See below my script:

hplot<-read.table("libl")
hplot
pdf("first_end")
hist(hplot$V1, breaks=24, xlim=c(0,250000000), ylim=c(0,2000000),main="first end mapping", xlab="Coordinates")
dev.off()

那么我应该如何更改脚本?

So how should I change my script? thx

推荐答案

您可以在绘制之前保存直方图数据以对其进行调整:

You can save the histogram data to tweak it before plotting:

set.seed(12345)
x = rnorm(1000)

hist.data = hist(x, plot=F)
hist.data$counts = log10(hist.data$counts)

dev.new(width=4, height=4)
hist(x)

dev.new(width=4, height=4)
plot(hist.data, ylab='log10(Frequency)')

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

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