[R] plotting segments only and in color

Eik Vettorazzi E.Vettorazzi at uke.uni-hamburg.de
Tue Aug 16 10:43:57 CEST 2011


Hi Johannes,
plot(X,Y,type="n")
creates an empty plot with correct dimensions,
ind<-!(Xb==Xa)
points(X[ind],Y[ind])
plots points for zero-length intervals only, and
gray()
can be used for shading lines, as in
segments(Xa,Y,Xb,Y,col=gray(.9*(Xb-Xa)/max(Xb-Xa)))
#the longest interval will be gray(.9) so it is just visible

hth.

Am 15.08.2011 18:01, schrieb Johannes Radinger:
> Hello,
> 
> I've a question concerning the display of interval data.
> 
> A sample dataset where X is an interval between Xa and Xb
> which should be displayed:
> 
> Y=c(15,14,23,18,19,9,19,13)
> Xa=c(17,22,21,18,19,25,8,19)
> Xb=c(22,22,29,34,19,26,17,22)
> X = (Xa+Xb)/2
> 
> 
> It's easily possible to plot the mean of the interval like:
> plot(X,Y)
> 
> afterwards I can create lines for the interval with:
> segments(Xa,Y,Xb,Y)
> 
> I think that explains roughly what I'd like to do.
> 
> Now some questions:
> 
> 1) How can I display the segments only? without the points?
> 
> 2) I'd like only to have points where the range (Xa-Xb) = 0, because
> otherwise nothing would be displayed in such cases.
> 
> 3) How can I color (grey scale) the interval-segments according to their range?
> Lets say the wider the range (Xa-Xb) the brighter (the more white)and the narrower the darker (more black)?
> 
> 4) Is there a special R-package or function besides for plotting interval, or ranging data?
> 
> Thanks
> 
> /johannes
> 
> 
> 
> --
> 
> ______________________________________________
> 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
Institut für Medizinische Biometrie und Epidemiologie
Universitätsklinikum Hamburg-Eppendorf

Martinistr. 52
20246 Hamburg

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



More information about the R-help mailing list