[R] About multiple panels with limited space in-between

lily li chocold12 at gmail.com
Wed Oct 11 00:13:20 CEST 2017


I use the code below to plot, but have some difficulties.

par(mfrow=c(2,5))
par(mar=c(2,1,1,0), oma=c(4,4,.5,.5))
plot(DF1$var1,DF1$A)
plot(DF1$var2,DF1$A, ylab=F); plot(DF1$var3,DF1$A,ylab=F);
plot(DF1$var4,DF1$A, ylab=F); plot(DF1$var5,DF1$A,ylab=F)
plot(DF2$var1,DF2$A)
plot(DF2$var2,DF2$A, ylab=F); plot(DF2$var3,DF2$A, ylab=F);
plot(DF2$var4,DF2$A, ylab=F); plot(DF2$var5,DF2$A, ylab=F)

Changing "ylab=F" to "labels=F" got the error message: "labels" is not a
graphical prameter.
For each row, I would like to use the leftmost y-axis, so the other figures
do not need to have y-axis. Then how to just have x-labels for the bottom
row, but have ticks and numbers in the x-labels for the top row? Also, I
forgot to attach the figure and here it is. This is more complicated, but I
just need two rows, and there are spaces between the two rows. Thanks first.

On Tue, Oct 10, 2017 at 2:41 PM, lily li <chocold12 at gmail.com> wrote:

> Hi R users,
>
> I have a question about plotting. The following two datasets are an
> example. What I have in mind is like the attached figure, but just have two
> rows, top row is for DF1, bottom row is for DF2. The top and bottom rows,
> have x-axis as var1, var2, var3, etc, while the y-axis represents A. For
> each row, only the leftmost panel has y-axis ticks and label. For the two
> rows, only the bottom row has x-axis ticks and label. I am not very clear
> about the coding. Thanks if you could give me any suggestions.
>
>
> DF1: Year 2000
> A     var1   var2   var3   var4   var5
> 1.2   0.8     0.9     1.1     1.2     12
> 1.8   0.9     1.2     1.0     2.1     15
> 1.5   0.7     1.1     0.9     2.2     16
> 1.6   0.9     1.0     0.7     2.5     18
> ...
>
> DF2: Year 2001
> A     var1   var2   var3   var4   var5
> 1.1   0.85     0.9     1.1     1.2     22
> 1.4   0.99     1.2     1.0     2.1     25
> 0.8   0.74     1.1     0.9     2.2     26
> 0.6   0.92     1.0     0.7     2.5     28
> ...
>
>


More information about the R-help mailing list