如何在R中以双对数刻度绘制宽范围数据?

huangapple go评论68阅读模式
英文:

How to plot wide range data in bi-symmetric logarithmic scale in R?

问题

I have a large dataset need to be displayed in log-scale. But a log transformation could loss the 0 and negative values. I found this figure in literature this kind of symmetric logarithmic scale is just what I need.

对于大型数据集,需要在对数刻度上显示。但对数转换可能会丢失0和负值。我在文献中找到了这张图,这种对称对数刻度正是我所需要的。

The pseudolog10_trans function is R package "ggallin" is not a solution.

R包“ggallin”中的pseudolog10_trans函数并不是一个解决方案。

I found a solution in Matlab: https://www.mathworks.com/matlabcentral/answers/292499-how-can-i-plot-negative-value-with-log-scale, how can I plot that in R that include all positive, negative and zero values in log-transformed scale?

我在Matlab中找到了一个解决方案:https://www.mathworks.com/matlabcentral/answers/292499-how-can-i-plot-negative-value-with-log-scale,如何在R中绘制这种图形,包括所有正数、负数和零值在对数变换刻度上?

Mathematical reference: https://kar.kent.ac.uk/32810/2/2012_Bi-symmetric-log-transformation_v5.pdf

数学参考资料:https://kar.kent.ac.uk/32810/2/2012_Bi-symmetric-log-transformation_v5.pdf

英文:

I have a large dataset need to be displayed in log-scale. But a log transformation could loss the 0 and negative values. I found this figure in literature this kind of symmetric logarithmic scale is just what I need.
Figure in bi-symmetric logarithmic scale

The pseudolog10_trans function is R package "ggallin" is not a solution.

I found a solution in Matlab: https://www.mathworks.com/matlabcentral/answers/292499-how-can-i-plot-negative-value-with-log-scale, how can I plot that in R that include all positive, negative and zero values in log-transformed scale?

Mathematical reference: https://kar.kent.ac.uk/32810/2/2012_Bi-symmetric-log-transformation_v5.pdf

答案1

得分: 0

定义一个函数,将输入转换为带符号对数并使用自定义坐标轴绘制。不使用任何包。

x <- c(-2000, -200, 20, 20, 200, 2000) # 测试输入

signed_log <- function(x) ifelse(x == 0, 0, sign(x) * log(abs(x)))

plot(signed_log(x), yaxt = "n", xlab = "", ylab = "", type = "o")
b <- c(-1000, -100, -10, 0, 10, 100, 1000)
axis(2, signed_log(b), b)

如何在R中以双对数刻度绘制宽范围数据?

英文:

Define a function to convert to signed log and plot the input with a custom axis. No packages are used.

x &lt;- c(-2000, -200, 20, 20, 200, 2000) # test input

signed_log &lt;- function(x) ifelse(x == 0, 0, sign(x) * log(abs(x)))

plot(signed_log(x), yaxt = &quot;n&quot;, xlab = &quot;&quot;, ylab = &quot;&quot;, type = &quot;o&quot;)
b &lt;- c(-1000, -100, -10, 0, 10, 100, 1000)
axis(2, signed_log(b), b)

如何在R中以双对数刻度绘制宽范围数据?

huangapple
  • 本文由 发表于 2023年5月10日 20:16:52
  • 转载请务必保留本文链接:https://go.coder-hub.com/76218315.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定