Changing mtext direction, or using text for the margin?

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

Changing mtext direction, or using text for the margin?

Michael Rennie-3

Hi all,

I have read through the archives, but can't find a solution to this problem.

I need the text direction on "dependent B", plotted in margin 4, to go
top to bottom (opposite what it is now). Here's some sample code:

#plot with mtext example

par(mgp = c(2,1,0), mfrow=c(2,2), las=1, mar=c(2,2,2,2), omi=
c(0.5,0.2,0,0.2))

a<-1:10
b<-7:16
c<-21:30

plot(a~b, ylab="", xlab="", xaxt="n")
axis(1, at=b, labels=FALSE, tick=TRUE)
plot(c~b, ylab="", xlab="", xaxt="n", yaxt="n")
axis(1, at=b, labels=FALSE, tick=TRUE)
axis(4, at=c(22,24,26,28,30), labels=TRUE, tick=TRUE)
plot(a~b, ylab="")
plot(c~b, ylab="", yaxt="n")
axis(4, at=c(22,24,26,28,30), labels=TRUE, tick=TRUE)

mtext(side=1, "independent", outer=TRUE, line=1, padj=1)
mtext(side=2, "dependent A", las=0, outer=TRUE, line=0.25)
mtext(side=4, "dependent B", las=0, outer=TRUE, line=0.25)

I have seen an example in help where i can use text and (srt) to
manipulate this with a single panel plot, but not for a multi-panel
example. Any help would be greatly appreciated.

Cheers,

Mike

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Changing mtext direction, or using text for the margin?

Uwe Ligges-3


On 07.01.2013 07:00, Michael Rennie wrote:

>
> Hi all,
>
> I have read through the archives, but can't find a solution to this
> problem.
>
> I need the text direction on "dependent B", plotted in margin 4, to go
> top to bottom (opposite what it is now). Here's some sample code:
>
> #plot with mtext example
>
> par(mgp = c(2,1,0), mfrow=c(2,2), las=1, mar=c(2,2,2,2), omi=
> c(0.5,0.2,0,0.2))
>
> a<-1:10
> b<-7:16
> c<-21:30
>
> plot(a~b, ylab="", xlab="", xaxt="n")
> axis(1, at=b, labels=FALSE, tick=TRUE)
> plot(c~b, ylab="", xlab="", xaxt="n", yaxt="n")
> axis(1, at=b, labels=FALSE, tick=TRUE)
> axis(4, at=c(22,24,26,28,30), labels=TRUE, tick=TRUE)
> plot(a~b, ylab="")
> plot(c~b, ylab="", yaxt="n")
> axis(4, at=c(22,24,26,28,30), labels=TRUE, tick=TRUE)
>
> mtext(side=1, "independent", outer=TRUE, line=1, padj=1)
> mtext(side=2, "dependent A", las=0, outer=TRUE, line=0.25)
> mtext(side=4, "dependent B", las=0, outer=TRUE, line=0.25)
>
> I have seen an example in help where i can use text and (srt) to
> manipulate this with a single panel plot, but not for a multi-panel
> example. Any help would be greatly appreciated.


You cannot do that with mtext, you rather need a dirty hack with text(),
I believe.

Best,
Uwe Ligges



> Cheers,
>
> Mike
>
> ______________________________________________
> [hidden email] 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.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Changing mtext direction, or using text for the margin?

Michael Rennie-3

Any thoughts on what that dirty hack might be or any leads on where to
start? Perhaps a whole new plot region in the margin or something? Is
that even possible? I'm having a difficult time imagining how I can do this.

Mike

Uwe Ligges wrote:

>
>
> On 07.01.2013 07:00, Michael Rennie wrote:
>>
>> Hi all,
>>
>> I have read through the archives, but can't find a solution to this
>> problem.
>>
>> I need the text direction on "dependent B", plotted in margin 4, to go
>> top to bottom (opposite what it is now). Here's some sample code:
>>
>> #plot with mtext example
>>
>> par(mgp = c(2,1,0), mfrow=c(2,2), las=1, mar=c(2,2,2,2), omi=
>> c(0.5,0.2,0,0.2))
>>
>> a<-1:10
>> b<-7:16
>> c<-21:30
>>
>> plot(a~b, ylab="", xlab="", xaxt="n")
>> axis(1, at=b, labels=FALSE, tick=TRUE)
>> plot(c~b, ylab="", xlab="", xaxt="n", yaxt="n")
>> axis(1, at=b, labels=FALSE, tick=TRUE)
>> axis(4, at=c(22,24,26,28,30), labels=TRUE, tick=TRUE)
>> plot(a~b, ylab="")
>> plot(c~b, ylab="", yaxt="n")
>> axis(4, at=c(22,24,26,28,30), labels=TRUE, tick=TRUE)
>>
>> mtext(side=1, "independent", outer=TRUE, line=1, padj=1)
>> mtext(side=2, "dependent A", las=0, outer=TRUE, line=0.25)
>> mtext(side=4, "dependent B", las=0, outer=TRUE, line=0.25)
>>
>> I have seen an example in help where i can use text and (srt) to
>> manipulate this with a single panel plot, but not for a multi-panel
>> example. Any help would be greatly appreciated.
>
>
> You cannot do that with mtext, you rather need a dirty hack with
> text(), I believe.
>
> Best,
> Uwe Ligges
>
>
>
>> Cheers,
>>
>> Mike
>>
>> ______________________________________________
>> [hidden email] 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.
>

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Changing mtext direction, or using text for the margin?

Uwe Ligges-3


On 07.01.2013 17:06, Michael Rennie wrote:
>
> Any thoughts on what that dirty hack might be or any leads on where to
> start? Perhaps a whole new plot region in the margin or something? Is
> that even possible? I'm having a difficult time imagining how I can do
> this.

Ideas fir ugly hacks:

Either use text() (and you rely on the spacing of the current device) or
try to use layout() and small figure at the reight hand size of all the
others.

Or go to the grid package and make it less ugly.

Best,
Uwe Ligges

>
> Mike
>
> Uwe Ligges wrote:
>>
>>
>> On 07.01.2013 07:00, Michael Rennie wrote:
>>>
>>> Hi all,
>>>
>>> I have read through the archives, but can't find a solution to this
>>> problem.
>>>
>>> I need the text direction on "dependent B", plotted in margin 4, to go
>>> top to bottom (opposite what it is now). Here's some sample code:
>>>
>>> #plot with mtext example
>>>
>>> par(mgp = c(2,1,0), mfrow=c(2,2), las=1, mar=c(2,2,2,2), omi=
>>> c(0.5,0.2,0,0.2))
>>>
>>> a<-1:10
>>> b<-7:16
>>> c<-21:30
>>>
>>> plot(a~b, ylab="", xlab="", xaxt="n")
>>> axis(1, at=b, labels=FALSE, tick=TRUE)
>>> plot(c~b, ylab="", xlab="", xaxt="n", yaxt="n")
>>> axis(1, at=b, labels=FALSE, tick=TRUE)
>>> axis(4, at=c(22,24,26,28,30), labels=TRUE, tick=TRUE)
>>> plot(a~b, ylab="")
>>> plot(c~b, ylab="", yaxt="n")
>>> axis(4, at=c(22,24,26,28,30), labels=TRUE, tick=TRUE)
>>>
>>> mtext(side=1, "independent", outer=TRUE, line=1, padj=1)
>>> mtext(side=2, "dependent A", las=0, outer=TRUE, line=0.25)
>>> mtext(side=4, "dependent B", las=0, outer=TRUE, line=0.25)
>>>
>>> I have seen an example in help where i can use text and (srt) to
>>> manipulate this with a single panel plot, but not for a multi-panel
>>> example. Any help would be greatly appreciated.
>>
>>
>> You cannot do that with mtext, you rather need a dirty hack with
>> text(), I believe.
>>
>> Best,
>> Uwe Ligges
>>
>>
>>
>>> Cheers,
>>>
>>> Mike
>>>
>>> ______________________________________________
>>> [hidden email] 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.
>>
>

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Changing mtext direction, or using text for the margin?

David Winsemius
In reply to this post by Michael Rennie-3

On Jan 7, 2013, at 8:06 AM, Michael Rennie wrote:

>
> Any thoughts on what that dirty hack might be or any leads on where  
> to start? Perhaps a whole new plot region in the margin or  
> something? Is that even possible? I'm having a difficult time  
> imagining how I can do this.

The `text` function accepts the 'xpd' argument for `par`.

?par
?text

(Similar but not exactly the same as R-FAQ "7.27 How can I create  
rotated axis labels?")

I'm not sure what sort of "dirt" Uwe was expecting, but I'm guessing  
he meant that you probably were not going to be getting exactly what  
you wanted with the first attempt and were going to need to adjust the  
locations "by hand" after digging around in the par documentation.

--
David.

> Mike
>
> Uwe Ligges wrote:
>>
>>
>> On 07.01.2013 07:00, Michael Rennie wrote:
>>>
>>> Hi all,
>>>
>>> I have read through the archives, but can't find a solution to this
>>> problem.
>>>
>>> I need the text direction on "dependent B", plotted in margin 4,  
>>> to go
>>> top to bottom (opposite what it is now). Here's some sample code:
>>>
>>> #plot with mtext example
>>>
>>> par(mgp = c(2,1,0), mfrow=c(2,2), las=1, mar=c(2,2,2,2), omi=
>>> c(0.5,0.2,0,0.2))
>>>
>>> a<-1:10
>>> b<-7:16
>>> c<-21:30
>>>
>>> plot(a~b, ylab="", xlab="", xaxt="n")
>>> axis(1, at=b, labels=FALSE, tick=TRUE)
>>> plot(c~b, ylab="", xlab="", xaxt="n", yaxt="n")
>>> axis(1, at=b, labels=FALSE, tick=TRUE)
>>> axis(4, at=c(22,24,26,28,30), labels=TRUE, tick=TRUE)
>>> plot(a~b, ylab="")
>>> plot(c~b, ylab="", yaxt="n")
>>> axis(4, at=c(22,24,26,28,30), labels=TRUE, tick=TRUE)
>>>
>>> mtext(side=1, "independent", outer=TRUE, line=1, padj=1)
>>> mtext(side=2, "dependent A", las=0, outer=TRUE, line=0.25)
>>> mtext(side=4, "dependent B", las=0, outer=TRUE, line=0.25)
>>>
>>> I have seen an example in help where i can use text and (srt) to
>>> manipulate this with a single panel plot, but not for a multi-panel
>>> example. Any help would be greatly appreciated.
>>
>>
>> You cannot do that with mtext, you rather need a dirty hack with  
>> text(), I believe.
>>
>> Best,
>> Uwe Ligges
>>
>>
>>
>>> Cheers,
>>>
>>> Mike
>>>
>>> ______________________________________________
>>> [hidden email] 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.
>>
>
> ______________________________________________
> [hidden email] 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.

David Winsemius, MD
Alameda, CA, USA

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Changing mtext direction, or using text for the margin?

Michael Rennie-3

Right- I think the issue is getting a text() command (which does accept
srt) to work outside the plot region, and in the margin where I need it
to appear. This is easy to "hack" in a single plot, but not so clear how
to do it in a multi-panel environment with an outer margin.

I suspect going to grid() is where I'm going to have to go (after
reading the relevant chapters in Paul Murrell's book....)

Mike

David Winsemius wrote:

>
> On Jan 7, 2013, at 8:06 AM, Michael Rennie wrote:
>
>>
>> Any thoughts on what that dirty hack might be or any leads on where
>> to start? Perhaps a whole new plot region in the margin or something?
>> Is that even possible? I'm having a difficult time imagining how I
>> can do this.
>
> The `text` function accepts the 'xpd' argument for `par`.
>
> ?par
> ?text
>
> (Similar but not exactly the same as R-FAQ "7.27 How can I create
> rotated axis labels?")
>
> I'm not sure what sort of "dirt" Uwe was expecting, but I'm guessing
> he meant that you probably were not going to be getting exactly what
> you wanted with the first attempt and were going to need to adjust the
> locations "by hand" after digging around in the par documentation.
>

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Changing mtext direction, or using text for the margin?

David Winsemius

On Jan 7, 2013, at 10:45 AM, Michael Rennie wrote:

>
> Right- I think the issue is getting a text() command (which does  
> accept srt) to work outside the plot region, and in the margin where  
> I need it to appear. This is easy to "hack" in a single plot, but  
> not so clear how to do it in a multi-panel environment with an outer  
> margin.
>
> I suspect going to grid() is where I'm going to have to go (after  
> reading the relevant chapters in Paul Murrell's book....)
>

If you are going that route you may want to look at the gridBase  
package.

--
David.

> Mike
>
> David Winsemius wrote:
>>
>> On Jan 7, 2013, at 8:06 AM, Michael Rennie wrote:
>>
>>>
>>> Any thoughts on what that dirty hack might be or any leads on  
>>> where to start? Perhaps a whole new plot region in the margin or  
>>> something? Is that even possible? I'm having a difficult time  
>>> imagining how I can do this.
>>
>> The `text` function accepts the 'xpd' argument for `par`.
>>
>> ?par
>> ?text
>>
>> (Similar but not exactly the same as R-FAQ "7.27 How can I create  
>> rotated axis labels?")
>>
>> I'm not sure what sort of "dirt" Uwe was expecting, but I'm  
>> guessing he meant that you probably were not going to be getting  
>> exactly what you wanted with the first attempt and were going to  
>> need to adjust the locations "by hand" after digging around in the  
>> par documentation.
>>
>

David Winsemius, MD
Alameda, CA, USA

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Changing mtext direction, or using text for the margin?

ilai-2
On Mon, Jan 7, 2013 at 11:52 AM, David Winsemius <[hidden email]>wrote:

>
> If you are going that route you may want to look at the gridBase package.
>
> Yes for mixing base and grid graphics but IMHO overkill here. Replacing
the last mtext line with

grid::grid.text('dependent B', 0.985 , 0.5 , rot = 270)

should take care of it (leaving exact placement and justification to the OP)

cheers



> --
> David.
>
>  Mike
>>
>> David Winsemius wrote:
>>
>>>
>>> On Jan 7, 2013, at 8:06 AM, Michael Rennie wrote:
>>>
>>>
>>>> Any thoughts on what that dirty hack might be or any leads on where to
>>>> start? Perhaps a whole new plot region in the margin or something? Is that
>>>> even possible? I'm having a difficult time imagining how I can do this.
>>>>
>>>
>>> The `text` function accepts the 'xpd' argument for `par`.
>>>
>>> ?par
>>> ?text
>>>
>>> (Similar but not exactly the same as R-FAQ "7.27 How can I create
>>> rotated axis labels?")
>>>
>>> I'm not sure what sort of "dirt" Uwe was expecting, but I'm guessing he
>>> meant that you probably were not going to be getting exactly what you
>>> wanted with the first attempt and were going to need to adjust the
>>> locations "by hand" after digging around in the par documentation.
>>>
>>>
>>
> David Winsemius, MD
> Alameda, CA, USA
>
> ______________________________**________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/**listinfo/r-help<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>
> and provide commented, minimal, self-contained, reproducible code.
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Changing mtext direction, or using text for the margin?

Michael Rennie-3

HA! Works perfectly!!! Thanks so much ilai.

ilai wrote:

>
> On Mon, Jan 7, 2013 at 11:52 AM, David Winsemius
> <[hidden email] <mailto:[hidden email]>> wrote:
>
>
>     If you are going that route you may want to look at the gridBase
>     package.
>
> Yes for mixing base and grid graphics but IMHO overkill here.
> Replacing the last mtext line with
>
> grid::grid.text('dependent B', 0.985 , 0.5 , rot = 270)
>
> should take care of it (leaving exact placement and justification to
> the OP)
>
> cheers
>
>     --
>     David.
>
>         Mike
>
>         David Winsemius wrote:
>
>
>             On Jan 7, 2013, at 8:06 AM, Michael Rennie wrote:
>
>
>                 Any thoughts on what that dirty hack might be or any
>                 leads on where to start? Perhaps a whole new plot
>                 region in the margin or something? Is that even
>                 possible? I'm having a difficult time imagining how I
>                 can do this.
>
>
>             The `text` function accepts the 'xpd' argument for `par`.
>
>             ?par
>             ?text
>
>             (Similar but not exactly the same as R-FAQ "7.27 How can I
>             create rotated axis labels?")
>
>             I'm not sure what sort of "dirt" Uwe was expecting, but
>             I'm guessing he meant that you probably were not going to
>             be getting exactly what you wanted with the first attempt
>             and were going to need to adjust the locations "by hand"
>             after digging around in the par documentation.
>
>
>
>     David Winsemius, MD
>     Alameda, CA, USA
>
>     ______________________________________________
>     [hidden email] <mailto:[hidden email]> 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.
>
>

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Changing mtext direction, or using text for the margin?

glsnow
In reply to this post by David Winsemius
And look at the grconvertX and grconvertY functions for possibly ways to
compute positioning information when using text with base graphics.


On Mon, Jan 7, 2013 at 11:35 AM, David Winsemius <[hidden email]>wrote:

>
> On Jan 7, 2013, at 8:06 AM, Michael Rennie wrote:
>
>
>> Any thoughts on what that dirty hack might be or any leads on where to
>> start? Perhaps a whole new plot region in the margin or something? Is that
>> even possible? I'm having a difficult time imagining how I can do this.
>>
>
> The `text` function accepts the 'xpd' argument for `par`.
>
> ?par
> ?text
>
> (Similar but not exactly the same as R-FAQ "7.27 How can I create rotated
> axis labels?")
>
> I'm not sure what sort of "dirt" Uwe was expecting, but I'm guessing he
> meant that you probably were not going to be getting exactly what you
> wanted with the first attempt and were going to need to adjust the
> locations "by hand" after digging around in the par documentation.
>
> --
> David.
>
>  Mike
>>
>> Uwe Ligges wrote:
>>
>>>
>>>
>>> On 07.01.2013 07:00, Michael Rennie wrote:
>>>
>>>>
>>>> Hi all,
>>>>
>>>> I have read through the archives, but can't find a solution to this
>>>> problem.
>>>>
>>>> I need the text direction on "dependent B", plotted in margin 4, to go
>>>> top to bottom (opposite what it is now). Here's some sample code:
>>>>
>>>> #plot with mtext example
>>>>
>>>> par(mgp = c(2,1,0), mfrow=c(2,2), las=1, mar=c(2,2,2,2), omi=
>>>> c(0.5,0.2,0,0.2))
>>>>
>>>> a<-1:10
>>>> b<-7:16
>>>> c<-21:30
>>>>
>>>> plot(a~b, ylab="", xlab="", xaxt="n")
>>>> axis(1, at=b, labels=FALSE, tick=TRUE)
>>>> plot(c~b, ylab="", xlab="", xaxt="n", yaxt="n")
>>>> axis(1, at=b, labels=FALSE, tick=TRUE)
>>>> axis(4, at=c(22,24,26,28,30), labels=TRUE, tick=TRUE)
>>>> plot(a~b, ylab="")
>>>> plot(c~b, ylab="", yaxt="n")
>>>> axis(4, at=c(22,24,26,28,30), labels=TRUE, tick=TRUE)
>>>>
>>>> mtext(side=1, "independent", outer=TRUE, line=1, padj=1)
>>>> mtext(side=2, "dependent A", las=0, outer=TRUE, line=0.25)
>>>> mtext(side=4, "dependent B", las=0, outer=TRUE, line=0.25)
>>>>
>>>> I have seen an example in help where i can use text and (srt) to
>>>> manipulate this with a single panel plot, but not for a multi-panel
>>>> example. Any help would be greatly appreciated.
>>>>
>>>
>>>
>>> You cannot do that with mtext, you rather need a dirty hack with text(),
>>> I believe.
>>>
>>> Best,
>>> Uwe Ligges
>>>
>>>
>>>
>>>  Cheers,
>>>>
>>>> Mike
>>>>
>>>> ______________________________**________________
>>>> [hidden email] mailing list
>>>> https://stat.ethz.ch/mailman/**listinfo/r-help<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>
>>>> and provide commented, minimal, self-contained, reproducible code.
>>>>
>>>
>>>
>> ______________________________**________________
>> [hidden email] mailing list
>> https://stat.ethz.ch/mailman/**listinfo/r-help<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>
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
> David Winsemius, MD
> Alameda, CA, USA
>
>
> ______________________________**________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/**listinfo/r-help<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>
> and provide commented, minimal, self-contained, reproducible code.
>



--
Gregory (Greg) L. Snow Ph.D.
[hidden email]

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Changing mtext direction, or using text for the margin?

David Carlson
Or use the "ugly hack" with a bit of locator() trial and error.
Replace the last mtext() call with

text(17.9, 31.9, "dependent B", srt=-90, xpd=NA, cex=1.25)

----------------------------------------------
David L Carlson
Associate Professor of Anthropology
Texas A&M University
College Station, TX 77843-4352


> -----Original Message-----
> From: [hidden email] [mailto:r-help-bounces@r-
> project.org] On Behalf Of Greg Snow
> Sent: Monday, January 07, 2013 3:59 PM
> To: David Winsemius
> Cc: r-help; Uwe Ligges; Michael Rennie
> Subject: Re: [R] Changing mtext direction, or using text for the
> margin?
>
> And look at the grconvertX and grconvertY functions for possibly ways
> to
> compute positioning information when using text with base graphics.
>
>
> On Mon, Jan 7, 2013 at 11:35 AM, David Winsemius
> <[hidden email]>wrote:
>
> >
> > On Jan 7, 2013, at 8:06 AM, Michael Rennie wrote:
> >
> >
> >> Any thoughts on what that dirty hack might be or any leads on where
> to
> >> start? Perhaps a whole new plot region in the margin or something?
> Is that
> >> even possible? I'm having a difficult time imagining how I can do
> this.
> >>
> >
> > The `text` function accepts the 'xpd' argument for `par`.
> >
> > ?par
> > ?text
> >
> > (Similar but not exactly the same as R-FAQ "7.27 How can I create
> rotated
> > axis labels?")
> >
> > I'm not sure what sort of "dirt" Uwe was expecting, but I'm guessing
> he
> > meant that you probably were not going to be getting exactly what you
> > wanted with the first attempt and were going to need to adjust the
> > locations "by hand" after digging around in the par documentation.
> >
> > --
> > David.
> >
> >  Mike
> >>
> >> Uwe Ligges wrote:
> >>
> >>>
> >>>
> >>> On 07.01.2013 07:00, Michael Rennie wrote:
> >>>
> >>>>
> >>>> Hi all,
> >>>>
> >>>> I have read through the archives, but can't find a solution to
> this
> >>>> problem.
> >>>>
> >>>> I need the text direction on "dependent B", plotted in margin 4,
> to go
> >>>> top to bottom (opposite what it is now). Here's some sample code:
> >>>>
> >>>> #plot with mtext example
> >>>>
> >>>> par(mgp = c(2,1,0), mfrow=c(2,2), las=1, mar=c(2,2,2,2), omi=
> >>>> c(0.5,0.2,0,0.2))
> >>>>
> >>>> a<-1:10
> >>>> b<-7:16
> >>>> c<-21:30
> >>>>
> >>>> plot(a~b, ylab="", xlab="", xaxt="n")
> >>>> axis(1, at=b, labels=FALSE, tick=TRUE)
> >>>> plot(c~b, ylab="", xlab="", xaxt="n", yaxt="n")
> >>>> axis(1, at=b, labels=FALSE, tick=TRUE)
> >>>> axis(4, at=c(22,24,26,28,30), labels=TRUE, tick=TRUE)
> >>>> plot(a~b, ylab="")
> >>>> plot(c~b, ylab="", yaxt="n")
> >>>> axis(4, at=c(22,24,26,28,30), labels=TRUE, tick=TRUE)
> >>>>
> >>>> mtext(side=1, "independent", outer=TRUE, line=1, padj=1)
> >>>> mtext(side=2, "dependent A", las=0, outer=TRUE, line=0.25)
> >>>> mtext(side=4, "dependent B", las=0, outer=TRUE, line=0.25)
> >>>>
> >>>> I have seen an example in help where i can use text and (srt) to
> >>>> manipulate this with a single panel plot, but not for a multi-
> panel
> >>>> example. Any help would be greatly appreciated.
> >>>>
> >>>
> >>>
> >>> You cannot do that with mtext, you rather need a dirty hack with
> text(),
> >>> I believe.
> >>>
> >>> Best,
> >>> Uwe Ligges
> >>>
> >>>
> >>>
> >>>  Cheers,
> >>>>
> >>>> Mike
> >>>>
> >>>> ______________________________**________________
> >>>> [hidden email] mailing list
> >>>> https://stat.ethz.ch/mailman/**listinfo/r-
> help<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>
> >>>> and provide commented, minimal, self-contained, reproducible code.
> >>>>
> >>>
> >>>
> >> ______________________________**________________
> >> [hidden email] mailing list
> >> https://stat.ethz.ch/mailman/**listinfo/r-
> help<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>
> >> and provide commented, minimal, self-contained, reproducible code.
> >>
> >
> > David Winsemius, MD
> > Alameda, CA, USA
> >
> >
> > ______________________________**________________
> > [hidden email] mailing list
> > https://stat.ethz.ch/mailman/**listinfo/r-
> help<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>
> > and provide commented, minimal, self-contained, reproducible code.
> >
>
>
>
> --
> Gregory (Greg) L. Snow Ph.D.
> [hidden email]
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] 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.

______________________________________________
[hidden email] 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.