Re: [R] reset par() within plot layout

2009-10-27 Thread Janke ten Holt
baptiste auguie wrote:
> Hi,
> 
>>From ?par,
> 
> "Value
> 
> When parameters are set, their former values are returned in an
> invisible named list."
> 
Wow, I must have missed that. Thanks,
Janke
> Therefore opar <- par(col="red") will not contain col="red".
> 
> HTH,
> 
> baptiste
> 
> 
> 2009/10/27 Janke ten Holt :
>> This seems to work indeed. But I don't understand why... I would think
>> that opar contains the par settings, including the col="red", but I
>> guess it doesn't. I will look into par's behaviour some more...
>> Thank you!
>>
>> Janke
>>> -Peter Ehlers
>>>

__
R-help@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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] reset par() within plot layout

2009-10-27 Thread baptiste auguie
Hi,

>From ?par,

"Value

When parameters are set, their former values are returned in an
invisible named list."

Therefore opar <- par(col="red") will not contain col="red".

HTH,

baptiste


2009/10/27 Janke ten Holt :
> This seems to work indeed. But I don't understand why... I would think
> that opar contains the par settings, including the col="red", but I
> guess it doesn't. I will look into par's behaviour some more...
> Thank you!
>
> Janke
>> -Peter Ehlers
>>

__
R-help@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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] reset par() within plot layout

2009-10-27 Thread Janke ten Holt
Tom Gottfried wrote:
> I think it would be much easier to use grid-graphics for your task. It's
> made for such things.
> 
> This is a good introduction:
> Paul Murrell. The grid graphics package. R News, 2(2):14-19, June 2002
> 
Thank you for your suggestion. I will certainly check it out.

Janke
> Tom
> 
> __
> R-help@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
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] reset par() within plot layout

2009-10-27 Thread Janke ten Holt


Peter Ehlers wrote:
> 
> 
> Janke ten Holt wrote:
>>
>> Tom Gottfried wrote:
>>> Janke,
>>>
>>> Janke ten Holt schrieb:
 Dear list,

 I would like to produce a matrix of plots, where par() is reset after
 each plot (see below [simplified] example). When I use layout() to do
 so, I seem to also reset the layout. I have not been able to figure out
 how to prevent this from happening.

 Any help is greatly appreciated!
 Janke

 Example code:
 #Desired result is a layout of 2 plots: one red and one black
 layout(matrix(1:2, nr=2))
 par.ini <- par(no.readonly=TRUE)
>>> look at par.ini: it's a list with all the argument-value pairs for
>>> par(). You might be able to solve
>>> your problem by removing the appropriate elements from par.ini before
>>> calling par(par.ini). Do the
>>> following to look which ones need to be kept for the layout:
>>>
>>> par()
>>> layout(matrix(1:2, nr=2))
>>> par()
>>>
>>> Tom
>>>
 par(col="red")
 plot(1:100)

 par(par.ini)

 plot(1:10)

 --
 Janke ten Holt
 Dept. of Psychology/Sociology
 University of Groningen, the Netherlands

 __
 R-help@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
 and provide commented, minimal, self-contained, reproducible code.
>>
>> Yes, that had occured to me too. So I tried:
>>
>> layout(matrix(1:2, nr=2))
>> par(no.readonly=TRUE)
>> plot(1:10)
>> par(no.readonly=TRUE)
>>
>> This has differences in
>> fig
>> mfg
>> usr
>> xaxp
>> yaxp
>>
>> But even keeping these back does not solve my problem. So I figured
>> there must be something else going on that I am unaware of...
>>
> 
> I think that what you want is
> 
>  layout(matrix(1:2, nr=2))
>  opar <- par(col="red")
>  plot(1:100)
>  par(opar)
>  plot(1:10)
> 
This seems to work indeed. But I don't understand why... I would think
that opar contains the par settings, including the col="red", but I
guess it doesn't. I will look into par's behaviour some more...
Thank you!

Janke
> -Peter Ehlers
> 
>> btw, your exact suggestion,
>>> par()
>>> layout(matrix(1:2, nr=2))
>>> par()
>> does not result in any differences.
>>
>> __
>> R-help@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
>> and provide commented, minimal, self-contained, reproducible code.
>>
>>

__
R-help@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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] reset par() within plot layout

2009-10-24 Thread Tom Gottfried
I think it would be much easier to use grid-graphics for your task.  
It's made for such things.


This is a good introduction:
Paul Murrell. The grid graphics package. R News, 2(2):14-19, June 2002

Tom

__
R-help@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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] reset par() within plot layout

2009-10-23 Thread Peter Ehlers



Janke ten Holt wrote:


Tom Gottfried wrote:

Janke,

Janke ten Holt schrieb:

Dear list,

I would like to produce a matrix of plots, where par() is reset after
each plot (see below [simplified] example). When I use layout() to do
so, I seem to also reset the layout. I have not been able to figure out
how to prevent this from happening.

Any help is greatly appreciated!
Janke

Example code:
#Desired result is a layout of 2 plots: one red and one black
layout(matrix(1:2, nr=2))
par.ini <- par(no.readonly=TRUE)

look at par.ini: it's a list with all the argument-value pairs for par(). You 
might be able to solve
your problem by removing the appropriate elements from par.ini before calling 
par(par.ini). Do the
following to look which ones need to be kept for the layout:

par()
layout(matrix(1:2, nr=2))
par()

Tom


par(col="red")
plot(1:100)

par(par.ini)

plot(1:10)

--
Janke ten Holt
Dept. of Psychology/Sociology
University of Groningen, the Netherlands

__
R-help@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
and provide commented, minimal, self-contained, reproducible code.


Yes, that had occured to me too. So I tried:

layout(matrix(1:2, nr=2))
par(no.readonly=TRUE)
plot(1:10)
par(no.readonly=TRUE)

This has differences in
fig
mfg
usr
xaxp
yaxp

But even keeping these back does not solve my problem. So I figured
there must be something else going on that I am unaware of...



I think that what you want is

 layout(matrix(1:2, nr=2))
 opar <- par(col="red")
 plot(1:100)
 par(opar)
 plot(1:10)

-Peter Ehlers


btw, your exact suggestion,

par()
layout(matrix(1:2, nr=2))
par()

does not result in any differences.

__
R-help@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
and provide commented, minimal, self-contained, reproducible code.




__
R-help@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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] reset par() within plot layout

2009-10-23 Thread Janke ten Holt


Tom Gottfried wrote:
> Janke,
> 
> Janke ten Holt schrieb:
>> Dear list,
>>
>> I would like to produce a matrix of plots, where par() is reset after
>> each plot (see below [simplified] example). When I use layout() to do
>> so, I seem to also reset the layout. I have not been able to figure out
>> how to prevent this from happening.
>>
>> Any help is greatly appreciated!
>> Janke
>>
>> Example code:
>> #Desired result is a layout of 2 plots: one red and one black
>> layout(matrix(1:2, nr=2))
>> par.ini <- par(no.readonly=TRUE)
> 
> look at par.ini: it's a list with all the argument-value pairs for par(). You 
> might be able to solve
> your problem by removing the appropriate elements from par.ini before calling 
> par(par.ini). Do the
> following to look which ones need to be kept for the layout:
> 
> par()
> layout(matrix(1:2, nr=2))
> par()
> 
> Tom
> 
>> par(col="red")
>> plot(1:100)
>>
>> par(par.ini)
>>
>> plot(1:10)
>>
>> --
>> Janke ten Holt
>> Dept. of Psychology/Sociology
>> University of Groningen, the Netherlands
>>
>> __
>> R-help@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
>> and provide commented, minimal, self-contained, reproducible code.

Yes, that had occured to me too. So I tried:

layout(matrix(1:2, nr=2))
par(no.readonly=TRUE)
plot(1:10)
par(no.readonly=TRUE)

This has differences in
fig
mfg
usr
xaxp
yaxp

But even keeping these back does not solve my problem. So I figured
there must be something else going on that I am unaware of...

btw, your exact suggestion,
> par()
> layout(matrix(1:2, nr=2))
> par()
does not result in any differences.

__
R-help@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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] reset par() within plot layout

2009-10-23 Thread Tom Gottfried
Janke,

Janke ten Holt schrieb:
> Dear list,
> 
> I would like to produce a matrix of plots, where par() is reset after
> each plot (see below [simplified] example). When I use layout() to do
> so, I seem to also reset the layout. I have not been able to figure out
> how to prevent this from happening.
> 
> Any help is greatly appreciated!
> Janke
> 
> Example code:
> #Desired result is a layout of 2 plots: one red and one black
> layout(matrix(1:2, nr=2))
> par.ini <- par(no.readonly=TRUE)

look at par.ini: it's a list with all the argument-value pairs for par(). You 
might be able to solve
your problem by removing the appropriate elements from par.ini before calling 
par(par.ini). Do the
following to look which ones need to be kept for the layout:

par()
layout(matrix(1:2, nr=2))
par()

Tom

> par(col="red")
> plot(1:100)
> 
> par(par.ini)
> 
> plot(1:10)
> 
> --
> Janke ten Holt
> Dept. of Psychology/Sociology
> University of Groningen, the Netherlands
> 
> __
> R-help@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
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] reset par() within plot layout

2009-10-23 Thread Janke ten Holt
OK, maybe I oversimplified the example, because you are of course correct...

I am working on a function, which I feed data to plot in layouts of
specified dimensions. I want to be able to set any par() variables for
each plot in the layout. Because the next plot does not know which par()
variables were changed in the previous plot, I want to reset all par()
variables after each plot, rather than simply change back one specific
par() variable.
So I really need to reset par() without 'messing with' my layout.

stephen sefick wrote:
> Maybe something like this?
> 
> #Desired result is a layout of 2 plots: one red and one black
> par(mfrow=c(2,1))
> 
> par(col="red")
> plot(1:100)
> 
> par(col="black")
> plot(1:10)
> 
> On Fri, Oct 23, 2009 at 7:26 AM, Janke ten Holt  wrote:
>> Dear list,
>>
>> I would like to produce a matrix of plots, where par() is reset after
>> each plot (see below [simplified] example). When I use layout() to do
>> so, I seem to also reset the layout. I have not been able to figure out
>> how to prevent this from happening.
>>
>> Any help is greatly appreciated!
>> Janke
>>
>> Example code:
>> #Desired result is a layout of 2 plots: one red and one black
>> layout(matrix(1:2, nr=2))
>> par.ini <- par(no.readonly=TRUE)
>> par(col="red")
>> plot(1:100)
>>
>> par(par.ini)
>>
>> plot(1:10)
>>
>> --
>> Janke ten Holt
>> Dept. of Psychology/Sociology
>> University of Groningen, the Netherlands
>>
>> __
>> R-help@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
>> and provide commented, minimal, self-contained, reproducible code.
>>
> 
> 
>

__
R-help@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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] reset par() within plot layout

2009-10-23 Thread stephen sefick
Maybe something like this?

#Desired result is a layout of 2 plots: one red and one black
par(mfrow=c(2,1))

par(col="red")
plot(1:100)

par(col="black")
plot(1:10)

On Fri, Oct 23, 2009 at 7:26 AM, Janke ten Holt  wrote:
> Dear list,
>
> I would like to produce a matrix of plots, where par() is reset after
> each plot (see below [simplified] example). When I use layout() to do
> so, I seem to also reset the layout. I have not been able to figure out
> how to prevent this from happening.
>
> Any help is greatly appreciated!
> Janke
>
> Example code:
> #Desired result is a layout of 2 plots: one red and one black
> layout(matrix(1:2, nr=2))
> par.ini <- par(no.readonly=TRUE)
> par(col="red")
> plot(1:100)
>
> par(par.ini)
>
> plot(1:10)
>
> --
> Janke ten Holt
> Dept. of Psychology/Sociology
> University of Groningen, the Netherlands
>
> __
> R-help@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
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Stephen Sefick

Let's not spend our time and resources thinking about things that are
so little or so large that all they really do for us is puff us up and
make us feel like gods.  We are mammals, and have not exhausted the
annoying little problems of being mammals.

-K. Mullis

__
R-help@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
and provide commented, minimal, self-contained, reproducible code.