[R] Fine control of plot

Sarah Goslee sarah.goslee at gmail.com
Tue Mar 12 20:33:40 CET 2013


Hi,

You posted in HTML by mistake, so your code was mangled:

> I'm trying to create a graph where I could plot some lines on the right side. Here an example:
> layout(matrix(c(1,2), 1, 2, byrow = TRUE), widths=c(6,2), heights=c(1,1))
> x = 1:100y = rnorm(x)+xplot(x,y)
> reg = lm(y~x)abline(reg, col = "red")
> plot(1, type="n", axes=F, xlab="", ylab="", xlim = c(-1,1), ylim = c(min(y), max(x)))segments(-0.25,min(reg$fitted.values),0.25,min(reg$fitted.values))segments(-0.25,max(reg$fitted.values),0.25,max(reg$fitted.values))segments(0,min(reg$fitted.values),0,max(reg$fitted.values))

I figured out where the linebreaks go, but I can't run this:

y = rnorm(x)+xplot(x,y)

What's xplot() doing here?

> However, I cant figure out how to make it a bit nicer by removing extra space to the right.

Can you explain further what you're trying to do? Plot spacing is
controlled with par() for base graphics, but I really don't understand
what you're after.

--
Sarah Goslee
http://www.functionaldiversity.org



More information about the R-help mailing list