How can I use the lwd to represent some quantity?
For instance:
plot(NULL, type="n", xlim=c(4,7), ylim=c(1,6), xlab="", ylab="")
points(c(5.25,5.25), c(4,5), type="l", lwd=87)
points(c(5.5,6.5), c(3.5,3.5), type="l", lwd=92)
rect(5,3,5.5,4, col="white")
I want the lines drawn with the points functions exactly as wide/tall as the rectangle. The values 87 and 92 above I found manually. Is there a way to calculate those quantities?
EDIT:
The background for the question is: I want to draw bezier curves, and I want the thickness of the curve represent my data. My first idea was to use lwd for that. Can I do better?
lwdis the wrong tool for what you’re trying to do. The actual line width will change relative to user coordinates depending on how your plot window is resized (or the dimensions when you save it). You obviously know about therectcommand, why not just use that? You might also look into theshapepackage.–Edit–
For more complex shapes, my experience doesn’t extend beyond
polygon. With that, you could get the coordinatesbcfor a Bezier curve, and then draw a polygon aroundx = c(bc$x + dx, rev(bc$x - dx), y = c(bc$y + dy, rev(bc$y - dy), but I’m not sure how well that would look for a complex curve.As an aside, you can replace
points(..., type = "l")withlines(...)if you’d like. (I think it makes my code more readable.)