Hello I have x <- c(0.5, 0.7, 3.5, 1.5, 2.5, 2.8) y <- c(0.5, 0.8, 1.5, 3.5, 1.5, 1.5) plot.default(x,y,type="p",panel.first=grid(5,5)) I need to plot that on a grid of 0,1,2,3,4,5 showing the grid lines on the these numbers. how can I do this? e.g how can I contorl the x and y min,max values on the plot and the location of the grid lines? thanks
plot(x, y, xlim=c(0,4), ylim=c(0,4)) grid() # OR ... abline( h=0:4, v=0:4, col="lightgray", lty=3 ) help(par) gives you more options to use in plot. grid() usually gives quite pretty results by default. On Fri, 2004-04-30 at 23:58, Fred J. wrote:> Hello > I have > x <- c(0.5, 0.7, 3.5, 1.5, 2.5, 2.8) > y <- c(0.5, 0.8, 1.5, 3.5, 1.5, 1.5) > plot.default(x,y,type="p",panel.first=grid(5,5)) > I need to plot that on a grid of 0,1,2,3,4,5 showing > the grid lines on the these numbers. how can I do > this? > e.g > how can I contorl the x and y min,max values on the > plot and the location of the grid lines? > > > thanks > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html >
Here's one way, maybe not the best... x <- c(0.5, 0.7, 3.5, 1.5, 2.5, 2.8) y <- c(0.5, 0.8, 1.5, 3.5, 1.5, 1.5) plot(x,y,type="p",xlim=c(0,5),ylim=c(0,5)) abline(h=seq(0,5),lty=2) abline(v=seq(0,5),lty=2) -----Original Message----- From: r-help-bounces at stat.math.ethz.ch [mailto:r-help-bounces at stat.math.ethz.ch]On Behalf Of Fred J. Sent: Friday, April 30, 2004 18:59 To: r help Subject: [R] grid location on plot Hello I have x <- c(0.5, 0.7, 3.5, 1.5, 2.5, 2.8) y <- c(0.5, 0.8, 1.5, 3.5, 1.5, 1.5) plot.default(x,y,type="p",panel.first=grid(5,5)) I need to plot that on a grid of 0,1,2,3,4,5 showing the grid lines on the these numbers. how can I do this? e.g how can I contorl the x and y min,max values on the plot and the location of the grid lines? thanks ______________________________________________ R-help at stat.math.ethz.ch mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reasonably Related Threads
- How to get a grid behind a boxplot
- help with making a function of scatter plot with multiple variables
- is there a way to avoid "traveling" grid?
- troubles with displaying legend on the plot
- como agrego una linea dibujada con abline() en la leyenda de un grafico ?