[R] Problem having tick marks aligned when plotting three graphs on top of one another.
Jim Holtman
jholtman at gmail.com
Sat Apr 23 06:18:40 CEST 2011
use 'plot' and 'lines'
plot(x,y1,ylim=range(c(y1,y2,y3)))
lines(x,y2)
lines(x,y3)
Sent from my iPad
On Apr 22, 2011, at 23:55, "John Sorkin" <jsorkin at grecc.umaryland.edu> wrote:
> R 2.10
> Windows 7
>
> I am trying to plot three graphs on top of each other. I need to have the axises perfectly aligned. For some reason the ticks on the y axes are slightly off so they do not perfectly align. Can someone tell me how I can get the to overlay each other perfectly? I thought the yaxp parameter would solve my problem, but it does not. My data and code follows:
>
>> summaryresults[1:20,]
> Slope PctCont PctCat PctTTst
> [1,] 0.05 7.4 5.6 6.3
> [2,] 0.10 17.7 11.3 13.3
> [3,] 0.15 32.7 18.7 25.6
> [4,] 0.20 53.3 27.5 40.2
> [5,] 0.25 72.1 41.2 54.5
> [6,] 0.30 85.5 52.9 70.8
> [7,] 0.35 93.9 65.2 83.6
> [8,] 0.40 97.0 73.6 89.9
> [9,] 0.45 99.7 84.8 96.5
> [10,] 0.50 99.9 90.1 98.4
> [11,] 0.55 100.0 93.2 99.7
> [12,] 0.60 100.0 97.3 99.8
> [13,] 0.65 100.0 98.8 100.0
> [14,] 0.70 100.0 99.4 100.0
> [15,] 0.75 100.0 99.8 100.0
> [16,] 0.80 100.0 99.7 100.0
> [17,] 0.85 100.0 100.0 100.0
> [18,] 0.90 100.0 100.0 100.0
> [19,] 0.95 100.0 100.0 100.0
> [20,] 1.00 100.0 100.0 100.0
>> plot(summaryresults[,"Slope"],summaryresults[,"PctCont"],type="b",yaxp=c(0,100,10))
>> par(new=TRUE)
>> plot(summaryresults[,"Slope"],summaryresults[,"PctCat"],type="b",yaxp=c(0,100,10))
>> par(new=TRUE)
>> plot(summaryresults[,"Slope"],summaryresults[,"PctTTst"],type="b",yaxp=c(0,100,10))
>
>
> John David Sorkin M.D., Ph.D.
> Chief, Biostatistics and Informatics
> University of Maryland School of Medicine Division of Gerontology
> Baltimore VA Medical Center
> 10 North Greene Street
> GRECC (BT/18/GR)
> Baltimore, MD 21201-1524
> (Phone) 410-605-7119
> (Fax) 410-605-7913 (Please call phone number above prior to faxing)
>
> Confidentiality Statement:
> This email message, including any attachments, is for th...{{dropped:6}}
>
> ______________________________________________
> 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.
More information about the R-help
mailing list