Vertical string with horizontal letters

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

Vertical string with horizontal letters

Israel Byrd

I'm trying to format text on a plot such that the string is vertical but the letters are horizonal.  I tried
text(1,1,label="output", srt=270)
This gives the string rotation I want, but that rotates the entire "output" so the letters are also rotated.  I've also tried
text(1,1,label="output", srt=270, crt=270)
to no avail.  par()$crt doesn't seem to affect text? The format I want is demonstrated below:

o
u
t
p
u
t

Thanks.
     
        [[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: Vertical string with horizontal letters

trinker


One possible solution is to use strsplit to break on each character and then paste to put in a "\n" after each character.  Then when you plot the text should be in the format you desire.
x <- "output"y <- unlist(strsplit(x, NULL))p <- cat(paste(y, collapse="\n"))
plot.new()text(.5, .5, paste(y, collapse="\n"))

cheersTyler----------------------------------------

> From: [hidden email]
> To: [hidden email]
> Date: Thu, 2 Feb 2012 17:20:17 +0000
> Subject: [R] Vertical string with horizontal letters
>
>
> I'm trying to format text on a plot such that the string is vertical but the letters are horizonal. I tried
> text(1,1,label="output", srt=270)
> This gives the string rotation I want, but that rotates the entire "output" so the letters are also rotated. I've also tried
> text(1,1,label="output", srt=270, crt=270)
> to no avail. par()$crt doesn't seem to affect text? The format I want is demonstrated below:
>
> o
> u
> t
> p
> u
> t
>
> Thanks.
>
> [[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.
Reply | Threaded
Open this post in threaded view
|

Re: Vertical string with horizontal letters

glsnow
In reply to this post by Israel Byrd
There are only a few graphics devices that honor the 'crt' setting to
rotate characters differently from the string rotation (postscript is
the only one I know of, and then not always).

For your specific case you could do something like:

> text(1,1, paste( unlist(strsplit('output','')), collapse='\n'), adj=c(0,1))

You could use gsub instead of the paste and strsplit, but it adds an
extra line feed at the beginning and end, or use:
gsub('(?<=.)(?=.)','\n','output', perl=TRUE)

You may also want to play around a little with the adj=c(0,1) to get
the positioning that you want.

On Thu, Feb 2, 2012 at 10:20 AM, Israel Byrd <[hidden email]> wrote:

>
> I'm trying to format text on a plot such that the string is vertical but the letters are horizonal.  I tried
> text(1,1,label="output", srt=270)
> This gives the string rotation I want, but that rotates the entire "output" so the letters are also rotated.  I've also tried
> text(1,1,label="output", srt=270, crt=270)
> to no avail.  par()$crt doesn't seem to affect text? The format I want is demonstrated below:
>
> o
> u
> t
> p
> u
> t
>
> Thanks.
>
>        [[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.
Reply | Threaded
Open this post in threaded view
|

Re: Vertical string with horizontal letters

trinker
In reply to this post by trinker

I apologize for the improperly formatted submission.  I had my hotmail set to plain text instead of rich text.
x <- "output"y <- unlist(strsplit(x, NULL))
plot.new()text(.5, .5, paste(y, collapse="\n"))

> From: [hidden email]
> To: [hidden email]; [hidden email]
> Date: Thu, 2 Feb 2012 13:08:17 -0500
> Subject: Re: [R] Vertical string with horizontal letters
>
>
>
> One possible solution is to use strsplit to break on each character and then paste to put in a "\n" after each character.  Then when you plot the text should be in the format you desire.
> x <- "output"y <- unlist(strsplit(x, NULL))p <- cat(paste(y, collapse="\n"))
> plot.new()text(.5, .5, paste(y, collapse="\n"))
>
> cheersTyler----------------------------------------
> > From: [hidden email]
> > To: [hidden email]
> > Date: Thu, 2 Feb 2012 17:20:17 +0000
> > Subject: [R] Vertical string with horizontal letters
> >
> >
> > I'm trying to format text on a plot such that the string is vertical but the letters are horizonal. I tried
> > text(1,1,label="output", srt=270)
> > This gives the string rotation I want, but that rotates the entire "output" so the letters are also rotated. I've also tried
> > text(1,1,label="output", srt=270, crt=270)
> > to no avail. par()$crt doesn't seem to affect text? The format I want is demonstrated below:
> >
> > o
> > u
> > t
> > p
> > u
> > t
> >
> > Thanks.
> >
> > [[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.
     
        [[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.