使用scale_x_continuous()正确处理-Inf和Inf标签和点

时间:2014-07-22 07:47:44

标签: r ggplot2

我想用包含Inf和-Inf值的变量制作gg散点图:

myDF <- data.frame(ratio = log2(0:6/6:0), intensity = rep(1, 7))

这是我的ggplot代码......

library(ggplot2)
p <- ggplot(myDF, aes(x = ratio, y = intensity)) +
       geom_point() 

enter image description here

...处理Inf和-Inf点没有问题。但是,我有两个问题:

问题1

如何获取标签?它们似乎超出了我scale_x_continuous所能访问的范围。

P + scale_x_continuous(breaks = seq(-2.5, 2.5, 0.5))

enter image description here

P + scale_x_continuous(breaks = seq(-5, 5, 1))

enter image description here

问题2

如何避免Inf和-Inf点在情节边缘被截断?我认为这是正确的方向,但并不完全在那里:

p + scale_x_continuous(expand = c(0.3, 0.3))

enter image description here

0 个答案:

没有答案