Grokbase Groups R r-help March 2002
FAQ
I'm making two plots, one on top of the other. On the upper plot, I do
not print the x-label or the x-tick-label. To reduce space, I'd like to
keep the white space between the two figures at a minimum. However, I
can't figure out how to methodically reduce the space while maintaining
the same figure dimensions for both plots. I could add margin space
below the lower plot and reduce space above the lower plot but that
leaves a bunch of whitespace at the bottom of the figure. What command
am I missing?
thanks,
Mike

Example commands:
mypar <- par(no.readonly=T)
par(mfcol=c(2,1))
par(mar=c(5,4,1,1))
plot(rnorm(100), ylim=c(-3,3), xlab="", axes=F)
axis(1, at=seq(0,100,20), labels=c("","","","","",""))
axis(2, at=seq(-3,3,1))
box()
plot(rnorm(100), ylim=c(-3,3), axes=F)
axis(1, at=seq(0,100,20))
axis(2, at=seq(-3,3,1))
box()
par(mypar)


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._

Search Discussions

  • Uwe Ligges at Mar 13, 2002 at 9:03 am

    "Michael D. Sohn" wrote:
    I'm making two plots, one on top of the other. On the upper plot, I do
    not print the x-label or the x-tick-label. To reduce space, I'd like to
    keep the white space between the two figures at a minimum. However, I
    can't figure out how to methodically reduce the space while maintaining
    the same figure dimensions for both plots. I could add margin space
    below the lower plot and reduce space above the lower plot but that
    leaves a bunch of whitespace at the bottom of the figure. What command
    am I missing?
    thanks,
    Mike

    Example commands:
    mypar <- par(no.readonly=T)
    par(mfcol=c(2,1))
    par(mar=c(5,4,1,1))
    plot(rnorm(100), ylim=c(-3,3), xlab="", axes=F)
    axis(1, at=seq(0,100,20), labels=c("","","","","",""))
    axis(2, at=seq(-3,3,1))
    box()
    plot(rnorm(100), ylim=c(-3,3), axes=F)
    axis(1, at=seq(0,100,20))
    axis(2, at=seq(-3,3,1))
    box()
    par(mypar)

    So you need more vertical space for the second than for the first plot.
    I would suggest to play with layout() and par(mar=...), but I'm not sure
    whether it is easy to calculate the distances *exactly*. Other
    suggestions are welcome.


    If you'll need only one figure of that kind, just use something like

    par(mfcol=c(2,1))
    par(mar=c(0.5,4,5,1)) ##### changed
    plot(rnorm(100), ylim=c(-3,3), xlab="", axes=F)
    axis(1, at=seq(0,100,20), labels=c("","","","","",""))
    axis(2, at=seq(-3,3,1))
    box()
    par(mar=c(5,4,0.5,1)) ####### added
    plot(rnorm(100), ylim=c(-3,3), axes=F)
    axis(1, at=seq(0,100,20))
    axis(2, at=seq(-3,3,1))
    box()

    and cut off the unused spaces with another appropriate software after
    that.

    Uwe Ligges
    -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
    r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
    Send "info", "help", or "[un]subscribe"
    (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
    _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
  • Bill Simpson at Mar 13, 2002 at 10:46 am

    On Wed, 13 Mar 2002, Uwe Ligges wrote:

    "Michael D. Sohn" wrote:
    I'm making two plots, one on top of the other. On the upper plot, I do
    not print the x-label or the x-tick-label. To reduce space, I'd like to
    keep the white space between the two figures at a minimum. However, I
    can't figure out how to methodically reduce the space while maintaining
    the same figure dimensions for both plots. I could add margin space
    below the lower plot and reduce space above the lower plot but that
    leaves a bunch of whitespace at the bottom of the figure. What command
    am I missing?
    I too would be greatly interested in being able to do this. For example if
    you have two plots stacked on top of each other, you would have only the
    ticks on the x-axis of the top plot and the full axis labels and title on
    the bottom plot. The size of the two plots must remain the same.

    So far as I know, this is not possible with R. What I have been doing is
    quite unsatisfactory: set the margins to the minimum acceptable. However
    this still leaves too much whitespace between the plots. If you really are
    motivated you can convert the figure from postscript to xfig or tgif
    format then edit manually. Not a great solution...

    pstoedit convert .ps file to tgif for editing:
    pstoedit -f tgif fig1.ps fig1.obj


    Bill

    -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
    r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
    Send "info", "help", or "[un]subscribe"
    (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
    _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
  • Achim Zeileis at Mar 13, 2002 at 1:18 pm
    On Wed, 13 Mar 2002, Bill Simpson wrote:
    On Wed, 13 Mar 2002, Uwe Ligges wrote:

    "Michael D. Sohn" wrote:
    I'm making two plots, one on top of the other. On the upper plot, I do
    not print the x-label or the x-tick-label. To reduce space, I'd like to
    keep the white space between the two figures at a minimum. However, I
    can't figure out how to methodically reduce the space while maintaining
    the same figure dimensions for both plots. I could add margin space
    below the lower plot and reduce space above the lower plot but that
    leaves a bunch of whitespace at the bottom of the figure. What command
    am I missing?
    I too would be greatly interested in being able to do this. For example if
    you have two plots stacked on top of each other, you would have only the
    ticks on the x-axis of the top plot and the full axis labels and title on
    the bottom plot. The size of the two plots must remain the same.

    So far as I know, this is not possible with R. What I have been doing is
    quite unsatisfactory: set the margins to the minimum acceptable. However
    this still leaves too much whitespace between the plots. If you really are
    motivated you can convert the figure from postscript to xfig or tgif
    format then edit manually. Not a great solution...

    pstoedit convert .ps file to tgif for editing:
    pstoedit -f tgif fig1.ps fig1.obj
    Well, maybe I don't get the problem, but you certainly have the
    possibility to have two (or more) plots with the same axis without wasting
    space in between (just like plot.mts() does for example).
    Just set that margins to 0 and don't plot the x-axis but for the last
    plot. For example you could do:

    par(mar = c(0, 5.1, 0, 2.1), oma = c(6, 0, 5, 0), mfrow=c(2,1))
    plot(rnorm(100), xaxt="n")
    plot(rnorm(100))

    The layout then is very similar to that of plot.mts() as in:

    plot(ts(cbind(rnorm(100), rnorm(100))), type = "p")

    I hope this is what you wanted...
    Z

    Bill

    -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
    r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
    Send "info", "help", or "[un]subscribe"
    (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
    _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._

    -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
    r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
    Send "info", "help", or "[un]subscribe"
    (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
    _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
  • Bill Simpson at Mar 13, 2002 at 2:46 pm
    Thanks very much Achim for the tip.

    This is what I wound up with:

    par(mar = c(0, 5.1, 1, 2.1), oma = c(6, 0, 5, 0), mfrow=c(2,1))
    par(pty="s")
    x<-rnorm(100)
    y<-rnorm(100)
    xticks<-pretty(x)
    yticks<-pretty(y)
    plot(x, y,axesúLSE,xlim=range(xticks), ylim=range(yticks))
    axis(side=1, at=xticks,labelsúLSE)
    axis(side=2, at=yticks)
    box()

    x1<-rnorm(100)
    y1<-rnorm(100)
    plot(x1,y1,axesúLSE,xlim=range(xticks), ylim=range(yticks))
    axis(side=1, at=xticks)
    axis(side=2, at=yticks)
    mtext("x",side=1,line=2)
    box()


    A lot of extra code was required because the only way I could see to get
    rid of tick labels is to turn of axes then add manually

    Bill

    -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
    r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
    Send "info", "help", or "[un]subscribe"
    (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
    _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupr-help @
categoriesr
postedMar 13, '02 at 7:48a
activeMar 13, '02 at 2:46p
posts5
users4
websiter-project.org
irc#r

People

Translate

site design / logo © 2017 Grokbase