[R] Does anybody know how to control the appearance of the end of the line in lattice?
Deepayan Sarkar
deepayan.sarkar at gmail.com
Tue Aug 17 11:26:50 CEST 2010
On Mon, Aug 9, 2010 at 1:19 AM, George Chen <glchen at stanford.edu> wrote:
> Hi All,
>
> I am plotting vertical lines using xyplot in lattice and type="h".
> It works well, but the problem is that the tops of the lines are convex and the bottoms are concave.
> Is there a way to flatten the tops and bottoms?
>
> Here's my code:
>
> Source<-matrix(1:30,10,3)
> colnames(Source)<-c("x","y1","y2")
> Source<-data.frame(Source)
>
> xyplot(y2+y1~x,
> data=Source,
> distribute.type=TRUE,
> type=c("h","h"),
> col=c("black","white"),
> lwd=20)
> graphics.off()
An additional note: If you actually want segments, then it would be
more natural to use
library(latticeExtra)
segplot(x ~ y2 + y1, data = Source, horizontal = FALSE,
col=c("black"), lwd=20)
To get flattened corners, you could use
segplot(x ~ y2 + y1, data = Source, horizontal = FALSE,
col=c("black"), lwd=20, lineend = "butt")
-Deepayan
More information about the R-help
mailing list