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?
data <- rnorm(1000, -3500, 27)
estimate <- -80000
plot(density(data))
abline(v = estimate)
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)
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.