Reputation: 63
I am writing a paper I plan to submit to an academic journal, and I want to use ggplot2 to follow a figure format similar to previous articles that use similar methods. I am trying to emulate the graph shown below, which has the following characteristics:
guide_axis_truncated()
(example post) could work, but most of the examples I see don't use the 0 // next-number notation that I'm looking for.guide_axis_truncated()
for this, but I'd appreciate a sanity check on this and recommendations on combining this with the right-side axis.Here is a link to the full-text article if that helps.
Upvotes: 1
Views: 299
Reputation: 73252
You might want to break away from ggplot and try base graphics. For the break marks on the axis (the gap in the broken axis) there exists plotrix::axis.break
. I strongly suggest to use a different device, such as pdf
, for better quality and not to get crazy.
par(mar=c(4, 4, 1, 3))
plot.new()
f1 <- 80; f2 <- 100
cax <- .8
plot.window(c(15, 60), c(0, 380))
axis(1, (0:6)*10, cex.axis=cax)
axis(1, par()$usr[1], labels='0', cex.axis=cax)
plotrix::axis.break(1, 15)
mtext(bquote(V[O[2]]~(ml*'*'*'kg'^-1*'*'*min^-1)), 1, 2.5)
axis(2, (0:4)*f1/4, las=2, cex.axis=cax)
plotrix::axis.break(2, 15)
mtext(bquote(f[R]~(breaths*'*'*'min'^-1)), 2, 2, at=40)
axis(2, (0:6)*f1/6 + f2, las=2, labels=formatC(c(0, seq.int(1.2, 3.2, .4)), digits=1, format='f'), cex.axis=cax)
axis(2, (2:12)*f1/12 + f2, las=2, labels=FALSE, tck=-.022, cex.axis=cax)
plotrix::axis.break(2, 107)
mtext(bquote(V[T]~(L)), 2, 2, at=140)
axis(2, (0:4)*f1/4 + f2*2, las=2, labels=c(0, seq.int(5, 35, 10)), cex.axis=cax)
plotrix::axis.break(2, 210)
mtext(bquote(V[E]/V[CO[2]]), 2, 2, at=240)
axis(2, (0:7)*f1/7 + f2*3, las=2, labels=c(0, seq.int(20, 50, 5)), cex.axis=cax)
plotrix::axis.break(2, 306)
mtext(bquote(V[E]/V[O[2]]), 2, 2, at=340)
abline(v=c(27, 45), lty=5)
axis(4, seq.int(0, 20, length.out=3) -10, pos=58, labels=formatC((0:2)/4, format='f', digits=2), las=2, cex.axis=cax)
axis(4, seq.int(0, 20, length.out=5) -10, pos=58, labels=FALSE, tck=-.022)
mtext(bquote(d^2*y/dx^2), 4, 2, at=0, cex=.9)
axis(4, seq.int(0, 20, length.out=3) + f2, pos=58, labels=formatC((-1:1)*.02, format='f', digits=2), las=2, cex.axis=cax, adj=0)
axis(4, seq.int(0, 20, length.out=5) + f2, pos=58, labels=FALSE, tck=-.022)
mtext(bquote(d^2*y/dx^2), 4, 2, at=110, cex=.9)
axis(4, seq.int(0, 30, length.out=4) + f2*2, pos=58, labels=formatC((-1:2)*.02, format='f', digits=2), las=2, cex.axis=cax)
axis(4, seq.int(0, 30, length.out=7) + f2*2, pos=58, labels=FALSE, tck=-.022)
mtext(bquote(d^2*y/dx^2), 4, 2, at=215, cex=.9)
axis(4, seq.int(0, 20, length.out=3) + f2*3, pos=58, labels=formatC((0:2)/20, format='f', digits=2), las=2, cex.axis=cax)
axis(4, seq.int(0, 20, length.out=5) + f2*3, pos=58, labels=FALSE, tck=-.022)
mtext(bquote(d^2*y/dx^2), 4, 2, at=310, cex=.9)
set.seed(42)
lines(seq.int(18, 52, length.out=50), runif(50, 20, 70))
lines(seq.int(18, 52, length.out=50), runif(50, -10, 0))
lines(seq.int(18, 52, length.out=50), runif(50, 0, 50)+110)
lines(seq.int(18, 52, length.out=50), runif(50, -10, 0)+110)
lines(seq.int(18, 52, length.out=50), runif(50, 5, 50)+220)
lines(seq.int(18, 52, length.out=50), runif(50, -10, 0)+220)
lines(seq.int(18, 52, length.out=50), runif(50, 0, 50)+320)
lines(seq.int(18, 52, length.out=50), runif(50, -10, 0)+320)
arrows(20, 300, 22, 314, length=.07)
text(20, 295, labels=bquote(GEX[1]), cex=.7)
arrows(52, 230, 48, 215, length=.07)
text(54, 233, labels=bquote(GEX[2]), cex=.7)
arrows(50, 92, 48, 100, length=.07)
text(51.5, 86, labels=bquote(V[T[2]]), cex=.7)
arrows(30, 8, 28, 0, length=.07)
text(31.5, 8, labels=bquote(f[R[1]]), cex=.7)
arrows(48, 8, 45, 0, length=.07)
text(49.5, 8, labels=bquote(f[R[2]]), cex=.7)
Upvotes: 0