我希望在我的情节中得到一个破X轴.在x轴上,我喜欢插入一个断轴符号< // >[从2开始到8结束,这意味着2-8将隐藏在< // >符号中],因此可以强调其他值.在Matlab中,此任务通过使用BreakXAxis执行.在R中,plotrix库只能插入一个断轴符号,就是这样.
x <- c(9.45, 8.78, 0.93, 0.47, 0.24, 0.12)
y <- c(10.72, 10.56, 10.35, 10.10, 9.13, 6.72)
z <- c(7.578, 7.456, 6.956, 6.712, 4.832, 3.345)
plot(x, y, col='blue', pch=16, xlab= 'x', ylab='y, z')
points(x, z, col='red', pch=17)
library(plotrix)
axis.break(1,2,style="slash")
Run Code Online (Sandbox Code Playgroud)
Rol*_*and 15
xgap <- ifelse(x > 8, x-6, x)
#Possibly you'd want to check if there are values between 2 and 8.
plot(xgap, y, col='blue', pch=16, xlab= 'x', ylab='y, z', xaxt="n")
points(xgap, z, col='red', pch=17)
xat <- pretty(xgap)
xat <- xat[xat!=2]
xlab <- ifelse(xat>2, xat+6, xat)
axis(1,at=xat, labels=xlab)
library(plotrix)
axis.break(1,2,style="slash")
Run Code Online (Sandbox Code Playgroud)

不要这样做.gap.plot提供了一个稍好的替代方案,但我可能会使用facet,例如ggplot2.
Jil*_*ina 15
听起来像你需要的 gap.plot
library(plotrix)
par(bty="n") # deleting the box
gap.plot(x,y, gap=c(2,7.5), gap.axis="x", pch=16,
col="blue", ylim=range(c(y,z)),
xtics=c(0:3,8:10), xticlab=c(0:3,8:10))
gap.plot(x,z, gap=c(2,7.5), gap.axis="x", pch=17,
col="red", ylim=range(c(y,z)), add=TRUE); axis(2)
abline(v=seq(1.99,2.09,.001), col="white") # hiding vertical lines
axis.break(1,2,style="slash") # plotting slashes for breakpoints
Run Code Online (Sandbox Code Playgroud)

| 归档时间: |
|
| 查看次数: |
33226 次 |
| 最近记录: |