I want to plot a distribution and a single value (with abline) which is very smaller than the minimum value in my distribution, so the abline won't appear in the plot. How can I plot them in the same plot manipulating the x-axis scale or maybe inserting breaks?
我想画一个分布和一个单独的值(带abline)它比我的分布中的最小值小得多,所以abline不会出现在图中。我如何将它们画在同一个图中操作x轴标尺或者插入断点?
data <- rnorm(1000, -3500, 27)
estimate <- -80000
plot(density(data))
abline(v = estimate)
2 个解决方案
#1
4
Here's a rough solution, it's not particularly pretty:
这里有一个粗略的解决方案,不是特别漂亮:
library(plotrix)
d <- density(data)
gap.plot(c(-8000,d$x), c(0,d$y), gap=range(c(-7990,-3620)),
gap.axis="x", type="l", xlab="x", ylab="Density",
xtics=c(-8000,seq(-3600,-3300,by=100)))
abline(v=-8000, col="red", lwd=2)
#2
0
Not exactly clear what is needed but this might be progress:
不清楚需要什么,但这可能是进展:
plot(density(data), xlim=range(c(data, estimate+10) ) )
abline(v = estimate, col='red')
In package:plotrix there are broken axis plotting functions.
在程序包中:plotrix中有破损的轴绘制函数。
#1
4
Here's a rough solution, it's not particularly pretty:
这里有一个粗略的解决方案,不是特别漂亮:
library(plotrix)
d <- density(data)
gap.plot(c(-8000,d$x), c(0,d$y), gap=range(c(-7990,-3620)),
gap.axis="x", type="l", xlab="x", ylab="Density",
xtics=c(-8000,seq(-3600,-3300,by=100)))
abline(v=-8000, col="red", lwd=2)
#2
0
Not exactly clear what is needed but this might be progress:
不清楚需要什么,但这可能是进展:
plot(density(data), xlim=range(c(data, estimate+10) ) )
abline(v = estimate, col='red')
In package:plotrix there are broken axis plotting functions.
在程序包中:plotrix中有破损的轴绘制函数。