[R] Fine control of plot

2013-03-12 Thread philippe massicotte
Hi everyone.
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))

However, I cant figure out how to make it a bit nicer by removing extra space 
to the right.
Any help would be greatly appreciated.
Regards,Phil  
[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] Fine control of plot

2013-03-12 Thread Sarah Goslee
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

__
R-help@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.


Re: [R] Fine control of plot

2013-03-12 Thread philippe massicotte
Hi and thank you for your answer. 

Sorry for the html post, here's the code: (you missed a break line between +x 
and plot(...) 

layout(matrix(c(1,2), 1, 2, byrow = TRUE), widths=c(6,2), heights=c(1,1)) 

x = 1:100 
y = rnorm(x)+x 
plot(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 hope my question is more obvious after you urn this example. 

Regards, 
Phil


 Date: Tue, 12 Mar 2013 15:33:40 -0400
 Subject: Re: [R] Fine control of plot
 From: sarah.gos...@gmail.com
 To: pmassico...@hotmail.com
 CC: r-help@r-project.org
 
 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  
__
R-help@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.


Re: [R] Fine control of plot

2013-03-12 Thread Sarah Goslee
Okay, so what you really want to do is be able to set a wide right
margin and draw some segments there? Using layout() is not the best
way to go about this: as you've discovered, you can't control the area
assigned.

You can cheat with layout(), as in:
layout(matrix(c(1,1,1,2), nrow=1))

but the better way is to see xpd within ?par as described here:
https://stat.ethz.ch/pipermail/r-help/2009-July/206311.html

along with par()$mai to set the margins appropriately.

Sarah

On Tue, Mar 12, 2013 at 3:50 PM, philippe massicotte
pmassico...@hotmail.com wrote:
 Hi and thank you for your answer.

 Sorry for the html post, here's the code: (you missed a break line between +x 
 and plot(...)

 layout(matrix(c(1,2), 1, 2, byrow = TRUE), widths=c(6,2), heights=c(1,1))

 x = 1:100
 y = rnorm(x)+x
 plot(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 hope my question is more obvious after you urn this example.

 Regards,
 Phil


 Date: Tue, 12 Mar 2013 15:33:40 -0400
 Subject: Re: [R] Fine control of plot
 From: sarah.gos...@gmail.com
 To: pmassico...@hotmail.com
 CC: r-help@r-project.org

 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

__
R-help@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.


Re: [R] Fine control of plot

2013-03-12 Thread philippe massicotte
xpd=TRUE might works well.

I'll give it a try.

Thank you for your assistance,
Phil

 Date: Tue, 12 Mar 2013 16:07:05 -0400
 Subject: Re: [R] Fine control of plot
 From: sarah.gos...@gmail.com
 To: pmassico...@hotmail.com
 CC: r-help@r-project.org

 Okay, so what you really want to do is be able to set a wide right
 margin and draw some segments there? Using layout() is not the best
 way to go about this: as you've discovered, you can't control the area
 assigned.

 You can cheat with layout(), as in:
 layout(matrix(c(1,1,1,2), nrow=1))

 but the better way is to see xpd within ?par as described here:
 https://stat.ethz.ch/pipermail/r-help/2009-July/206311.html

 along with par()$mai to set the margins appropriately.

 Sarah

 On Tue, Mar 12, 2013 at 3:50 PM, philippe massicotte
 pmassico...@hotmail.com wrote:
  Hi and thank you for your answer.
 
  Sorry for the html post, here's the code: (you missed a break line between 
  +x and plot(...)
 
  layout(matrix(c(1,2), 1, 2, byrow = TRUE), widths=c(6,2), heights=c(1,1))
 
  x = 1:100
  y = rnorm(x)+x
  plot(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 hope my question is more obvious after you urn this example.
 
  Regards,
  Phil
 
 
  Date: Tue, 12 Mar 2013 15:33:40 -0400
  Subject: Re: [R] Fine control of plot
  From: sarah.gos...@gmail.com
  To: pmassico...@hotmail.com
  CC: r-help@r-project.org
 
  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  
__
R-help@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.