I need your help because I want to have a logarithmic scale for my histogram and boxplot. The problem is that I have many observation which are concentrate in a little interval, and I think using logarithmic scale will solve my issue. For example,
我需要你的帮助,因为我希望我的直方图和箱形图有一个对数刻度。问题是我有很多观察集中在一个小间隔,我认为使用对数标度将解决我的问题。例如,
x
y
z
par(mfrow=c(1,2))
hist(z, main="Histogramme des durées",
ylab="Fréquences")
boxplot(z, main="Boîtes des durées")
par(mfrow=c(1,1))
It's very difficult to analyze my data, so I tried to add log = "x" but it don't do what I want !
分析我的数据非常困难,所以我尝试添加log =“x”,但它没有做我想要的!
Thank you in advance.
先谢谢你。
1 个解决方案
#1
1
Instead of scaling the plot axis, you could plot the logarithm of the data.
您可以绘制数据的对数,而不是缩放绘图轴。
par(mfrow=c(1,2))
hist(log(z), main="Histogramme des durées",ylab="Fréquences")
boxplot(log(z), main="Boîtes des durées")
If you want the axis scale to be in the original units (not logarithmic units), you can change the axis tick labels.
如果希望轴刻度为原始单位(不是对数单位),则可以更改轴刻度标签。
par(mfrow=c(1,2))
hist(log10(z), xaxt='n',xlab='',main="Histogramme des durées",ylab="Fréquences")
atx
labels
as.expression(bquote(10^.(i) ))
)
axis(1,at=atx,labels=labels)
boxplot(log10(z),yaxt='n', ylab='z',main="Boîtes des durées")
aty
labels
as.expression(bquote(10^.(i) ))
)
axis(2,at=aty,labels=labels)