Andrew Johnson
2003-Jul-15 19:42 UTC
[R] Plotting a graph of many lines between groups of points...
I have a data file read into a data frame. For example, V1 V2 V3 V4 1 1 1 3 4 2 2 3 5 10 . . . . . . . . . . n V1[n] V2[n] V3[n] V4[n] to n=many thousand I want to plot a graph with many line segments, where v1[i]=x1, v2[i]=y1, v3[i]=x2, v4[i]=y2 for i=1,n. This seems relatively simple in theory but I've spent quite a bit of time trying to make it happen with plot(type=), points(x,y), or lines(x,y) to no avail. Do I need to turn these into vectors before plotting them? Any help would be greatly appreciated. Thanks, Andrew
Joel Kincaid
2003-Jul-15 20:21 UTC
[R] Plotting a graph of many lines between groups of points...
johnson.2060 at osu.edu wrote:> I have a data file read into a data frame. > > For example, > > V1 V2 V3 V4 > 1 1 1 3 4 > 2 2 3 5 10 > . . . . . > . . . . . > n V1[n] V2[n] V3[n] V4[n] > > to n=many thousand >is this stored as a data.frame? a matrix? In any case there seems to be a problem with your indexing ...> I want to plot a graph with many line segments, where v1[i]=x1,v2[i]=y1,> v3[i]=x2, v4[i]=y2 for i=1,n.indexing is ok if you have df$v3[i] ....> > This seems relatively simple in theory but I've spent quite a bit oftime> trying to make it happen with plot(type=), points(x,y), or lines(x,y)to no> avail.could you send the actual code for your plot? Perhaps some way to construct the data. at this point things are a bit murky.> > Do I need to turn these into vectors before plotting them?Thus my question about how the data are stored...> > Any help would be greatly appreciated. > > Thanks, > Andrew > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-helpCheers, Joel Joel F. Kincaid, Ph. D. Assistant Professor Department of Economics and Finance Franklin P. Perdue School of Business Salisbury University Salisbury Maryland, 21801 Phone: (410) 548-4416 Email: jfkincaid at salisbury.edu
Joel Kincaid
2003-Jul-15 20:30 UTC
[R] Plotting a graph of many lines between groups of points...
johnson.2060 at osu.edu wrote: > I have a data file read into a data frame. > > For example, > > V1 V2 V3 V4 > 1 1 1 3 4 > 2 2 3 5 10 > . . . . . > . . . . . > n V1[n] V2[n] V3[n] V4[n] > > to n=many thousand > is this stored as a data.frame? a matrix? In any case there seems to be a problem with your indexing ... > I want to plot a graph with many line segments, where v1[i]=x1, v2[i]=y1, > v3[i]=x2, v4[i]=y2 for i=1,n. indexing is ok if you have df$v3[i] .... > > This seems relatively simple in theory but I've spent quite a bit of time > trying to make it happen with plot(type=), points(x,y), or lines(x,y) to no > avail. could you send the actual code for your plot? Perhaps some way to construct the data. at this point things are a bit murky. > > Do I need to turn these into vectors before plotting them? Thus my question about how the data are stored... > > Any help would be greatly appreciated. > > Thanks, > Andrew > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help Cheers, Joel Joel F. Kincaid, Ph. D. Assistant Professor Department of Economics and Finance Franklin P. Perdue School of Business Salisbury University Salisbury Maryland, 21801 Phone: (410) 548-4416 Email: jfkincaid at salisbury.edu
Hotz, T.
2003-Jul-16 08:41 UTC
[R] Plotting a graph of many lines between groups of points...
Dear Andrew, Assuming your variables are called V1 to V4, and are vectors, I'd use something like plot(V1,V2,xlim=range(V1,V3),ylim=range(V2,V4),type="n") segments(V1,V2,V3,V4) HTH Thomas --- Thomas Hotz Research Associate in Medical Statistics University of Leicester United Kingdom Department of Epidemiology and Public Health 22-28 Princess Road West Leicester LE1 6TP Tel +44 116 252-5410 Fax +44 116 252-5423 Division of Medicine for the Elderly Department of Medicine The Glenfield Hospital Leicester LE3 9QP Tel +44 116 256-3643 Fax +44 116 232-2976> -----Original Message----- > From: Andrew Johnson [mailto:johnson.2060 at osu.edu] > Sent: 15 July 2003 20:42 > To: r-help at stat.math.ethz.ch > Subject: [R] Plotting a graph of many lines between groups of > points... > > > I have a data file read into a data frame. > > For example, > > V1 V2 V3 V4 > 1 1 1 3 4 > 2 2 3 5 10 > . . . . . > . . . . . > n V1[n] V2[n] V3[n] V4[n] > > to n=many thousand > > I want to plot a graph with many line segments, where > v1[i]=x1, v2[i]=y1, > v3[i]=x2, v4[i]=y2 for i=1,n. > > This seems relatively simple in theory but I've spent quite a > bit of time > trying to make it happen with plot(type=), points(x,y), or > lines(x,y) to no > avail. > > Do I need to turn these into vectors before plotting them? > > Any help would be greatly appreciated. > > Thanks, > Andrew > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help >