[R] textplot in layout

Eik Vettorazzi E.Vettorazzi at uke.de
Tue Oct 25 16:12:08 CEST 2011


Hi Ben,
maybe mtext is of more help here?

par(mar=c(7,3,3,3))
plot(year,rate,main='main',sub='sub')
mtext('test',cex=1,side=1,line=5)
box()

cheers

Am 25.10.2011 15:26, schrieb Ben quant:
> Hello,
> 
> Someone (Erik) recently posted about putting text on a plot. That thread
> didn't help. I'd like to put text directly below the 'sub' text (with no
> gap). The code below is the best I can do. Note the large undesirable gap
> between 'sub' and 'test'. I'd like the word 'test' to be just below the top
> box() boarder (directly below 'sub').
> 
> year <- c(2000 ,   2001  ,  2002  ,  2003 ,   2004)
> rate <- c(9.34 ,   8.50  ,  7.62  ,  6.93  ,  6.60)
> op <- par(no.readonly = TRUE)
> on.exit(par(op))
> layout(matrix(c(1,2), 2, 1, byrow = TRUE),heights=c(8,1))
> par(mar=c(5,3,3,3))
> plot(year,rate,main='main',sub='sub')
> library(gplots)
> par(mar=c(0,0,0,0),new=F)
> textplot('test',valign='top',cex=1)
> box()
> 
> Note: I'd rather solve it with textplot. If not, my next stop is
> grid.text(). Also, the text I am plotting with textplot is much longer so a
> multiple line text plot would solve my next issue (of which I have not
> looked into yet). Lastly, layout is not necessary. I just used it because I
> thought it would do what I wanted.
> 
> Thanks,
> 
> Ben
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> 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
> and provide commented, minimal, self-contained, reproducible code.


-- 
Eik Vettorazzi

Department of Medical Biometry and Epidemiology
University Medical Center Hamburg-Eppendorf

Martinistr. 52
20246 Hamburg

T ++49/40/7410-58243
F ++49/40/7410-57790

--
Pflichtangaben gemäß Gesetz über elektronische Handelsregister und Genossenschaftsregister sowie das Unternehmensregister (EHUG):

Universitätsklinikum Hamburg-Eppendorf; Körperschaft des öffentlichen Rechts; Gerichtsstand: Hamburg

Vorstandsmitglieder: Prof. Dr. Guido Sauter (Vertreter des Vorsitzenden), Dr. Alexander Kirstein, Joachim Prölß, Prof. Dr. Dr. Uwe Koch-Gromus 



More information about the R-help mailing list