I want to plot a straight line where y=m*x+1 (where x varying from -5 to +5) and and m will change from 0.5 to 5. All the straight lines needs to be overlaid. Thanks Parth
That you want to do this is fascinating. Since you are so intent on doing this I am sure you have already Googled "R plot several lines" and used the examples you found to help make your plots by now. Do keep in mind that there are three common but distinctly different graphing systems available in R: base graphics, lattice graphics, and the ggplot2 package. The first two come with the base software, while the third requires a package from CRAN. Each has advantages and disadvantages, so do try out each while you are at it. What you don't appear to have done is read the Posting Guide or the footer in any message on this list. This list is not here to to your work/homework for you, and a reproducible example illustrating just where you are having difficulty will let us help you get out of a bind much more effectively than just doing your work for you from scratch. --------------------------------------------------------------------------- Jeff Newmiller The ..... ..... Go Live... DCN:<jdnewmil at dcn.davis.ca.us> Basics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/Batteries O.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --------------------------------------------------------------------------- Sent from my phone. Please excuse my brevity. On March 15, 2015 9:03:07 PM PDT, Partha Sinha <pnsinha68 at gmail.com> wrote:>I want to plot a straight line where y=m*x+1 (where x varying from -5 >to +5) and and m will change from 0.5 to 5. All the straight lines >needs to be overlaid. >Thanks >Parth > >______________________________________________ >R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see >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.
Something like this might help you get started. x <- seq(-5, 5, 1) m <- seq(0.5, 5, 0.5) plot(0, 0, type="n", xlab="", ylab="", xlim=range(x), ylim=range(outer(m, x)+1)) invisible(lapply(m, function(slope) abline(1, slope))) Jean On Sun, Mar 15, 2015 at 11:03 PM, Partha Sinha <pnsinha68 at gmail.com> wrote:> I want to plot a straight line where y=m*x+1 (where x varying from -5 > to +5) and and m will change from 0.5 to 5. All the straight lines > needs to be overlaid. > Thanks > Parth > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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. >[[alternative HTML version deleted]]