[R] Interaction plots (six on one page)

ukoenig at med.uni-marburg.de ukoenig at med.uni-marburg.de
Wed Jul 1 15:00:54 CEST 2009


Now it works, I modified one variable (xleg) in the function,
Thanks a lot!


Quoting jim holtman <jholtman at gmail.com>:

> It appears that the legend is fixed in that location within the funciton.
> You could modify the function to put the legend in some other location.
>
> On Wed, Jul 1, 2009 at 3:07 AM, <ukoenig at med.uni-marburg.de> wrote:
>
>> Thank you, Jim!
>>
>> It looks much better with that new aspect ratio!
>>
>> Unfortunately the legend is located at the same place,
>> too far on the rigt side next to the border.
>> Any ideas?
>>
>> Thanks, Udo
>>
>>
>>
>>
>> Quoting jim holtman <jholtman at gmail.com>:
>>
>>   add
>>>
>>>    par(mar=c(2.5,4,1,1))
>>>
>>> just after layout
>>>
>>> On Tue, Jun 30, 2009 at 4:20 PM, <ukoenig at med.uni-marburg.de> wrote:
>>>
>>>   #Dear R users,
>>>> #I want six interaction plots to be on one page,
>>>> #but the following problem occurs: the legend "BMIakt" appears,
>>>> #but it is exactly on the border of the plots (too far right).
>>>> #My seccond question is, how I can reduce the empty space in the
>>>> y-direction
>>>> #between the plots.
>>>>
>>>> #Please have a look at my syntax below.
>>>>
>>>> #Many thanks!
>>>> #Udo
>>>>
>>>>
>>>> myData <-
>>>> ("id,BMIakt,time,thanaa,thalcho,thalino,ponaa,pocho,poino
>>>> 1,0,1,1.63,0.79,0.28,1.63,0.98,0.58
>>>> 2,0,2,1.7,0.72,0.37,1.83,0.97,0.42
>>>> 3,1,1,1.73,0.83,0.32,2.24,1,0.88
>>>> 4,1,2,1.87,0.76,0.49,1.78,0.68,0.61
>>>> 5,0,1,1.81,0.99,0.47,1.98,0.96,0.6
>>>> 6,0,2,1.7,0.77,0.38,1.68,0.79,0.51
>>>> 7,0,1,1.79,0.95,0.48,1.65,0.9,0.73
>>>> 8,0,2,2.5,0.79,0.56,2.09,0.81,0.64
>>>> 9,1,1,1.63,0.71,0.36,2.13,0.98,0.68
>>>> 10,1,2,1.69,0.85,0.43,2,0.94,0.59
>>>> 11,1,1,1.95,1.04,0.38,1.7,0.92,0.47
>>>> 12,1,2,2.16,0.84,0.25,2.01,0.73,0.38
>>>> 13,0,1,1.65,0.8,0.2,1.74,0.95,0.43
>>>> 14,0,2,1.83,0.96,0.59,1.88,1.2,0.73
>>>> 15,1,1,2.02,0.79,0.26,2.01,0.94,0.59
>>>> 16,1,2,1.71,0.57,0.42,1.87,0.73,0.59
>>>> 17,1,1,1.5,0.78,0.35,1.68,0.84,0.48
>>>> 18,1,2,1.4,0.66,0.43,1.87,1.02,0.39
>>>> 19,1,1,1.45,0.69,0.32,1.74,0.67,0.44
>>>> 20,1,2,1.65,0.88,0.27,1.7,0.87,0.55
>>>> 21,1,1,1.89,0.66,0.4,1.93,0.88,0.58
>>>> 22,1,2,1.71,0.81,0.34,1.87,0.8,0.53
>>>> 23,1,1,1.71,0.87,0.34,1.65,1.16,0.65
>>>> 24,1,2,1.82,1.29,0.49,1.98,1.31,0.57
>>>> 25,1,1,1.66,0.86,0.28,1.4,0.8,0.38
>>>> 26,1,2,1.82,0.82,0.45,1.4,1.1,0.68
>>>> 27,1,1,1.67,0.71,0.32,1.83,0.84,0.63
>>>> 28,1,2,2.06,0.69,0.41,1.62,0.9,0.57
>>>> 29,1,1,1.62,0.81,0.47,1.88,1.11,0.6
>>>> 30,1,2,1.76,0.77,0.71,1.74,1.2,0.55
>>>> 31,0,1,1.8,0.78,0.27,1.96,0.86,0.47
>>>> 32,0,2,1.7,0.63,0.35,2.22,0.83,0.58
>>>> 33,1,1,1.92,0.8,0.37,1.8,0.98,0.43
>>>> 34,1,2,1.94,0.84,0.48,1.92,0.86,0.61
>>>> 35,1,1,1.55,0.6,0.44,1.78,0.86,0.64
>>>> 36,1,2,1.68,0.61,0.39,1.84,0.85,0.65
>>>> 37,0,1,1.77,0.84,0.47,1.72,0.84,0.57
>>>> 38,0,2,1.79,0.85,0.55,1.89,0.85,0.54
>>>> 39,1,1,1.87,0.9,0.52,2.01,1.01,0.7
>>>> 40,1,2,1.91,0.72,0.28,1.81,0.78,0.65")
>>>>
>>>> data <- read.table(textConnection(myData),
>>>>    header=TRUE, sep=",", row.names="id")
>>>>
>>>> attach(data)
>>>> layout(matrix(1:6, 3, 2))
>>>>
>>>>
>>>> interaction.plot(time, BMIakt, thanaa)
>>>> interaction.plot(time, BMIakt, thalcho)
>>>> interaction.plot(time, BMIakt, thalino)
>>>> interaction.plot(time, BMIakt, ponaa)
>>>> interaction.plot(time, BMIakt, pocho)
>>>> interaction.plot(time, BMIakt, poino)
>>>>
>>>>
>>>> #Using "locator()" would be an alternative, but the text "BMIakt" is
>>>> missing,
>>>> #doing that
>>>> interaction.plot(time, BMIakt175, thanaa, legend=FALSE)
>>>> legend(locator(1), c("1", "0"), cex=0.8, col=c("black", "black"),
>>>> lty=1:2)
>>>>
>>>> ______________________________________________
>>>> R-help at r-project.org mailing list
>>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>>> PLEASE do read the posting guide
>>>> http://www.R-project.org/posting-guide.html<http://www.r-project.org/posting-guide.html>
>>>> <http://www.r-project.org/posting-guide.html>
>>>> and provide commented, minimal, self-contained, reproducible code.
>>>>
>>>>
>>>
>>>
>>> --
>>> Jim Holtman
>>> Cincinnati, OH
>>> +1 513 646 9390
>>>
>>> What is the problem that you are trying to solve?
>>>
>>>
>>
>>
>
>
> --
> Jim Holtman
> Cincinnati, OH
> +1 513 646 9390
>
> What is the problem that you are trying to solve?
>




More information about the R-help mailing list