Re: [R] Plotting lines with equidistant points for identification

From: Jim Lemon <jim_at_bitwrit.com.au>
Date: Tue, 19 Apr 2011 18:31:45 +1000

On 04/19/2011 06:05 PM, Timo Schneider wrote:
> Dear R Gurus,
>
> I would like to make a line-plot of a large data-set (>200 data-points)
> for a document which will be printed in black and white. The plot will
> contain 5 different lines. So i need a way to differentiate between the
> lines. Since color is not an option i tried different line styles with
> all sorts of "line-gap" or "dot dot dot" patterns. Since my plots are
> rather small it is hard to get lines that look contiguous enough while
> still being identifiable through their line style.
>
> What I would like to have are lines that have symbols on top of them,
> similar to what i get with plot(x,y,type='o'). The problem is that i
> have to many data-points for that method, the symbols will just "melt
> together", as in plot(seq(1,500), seq(1,500), type='o') - just one big
> line.
>
> What i want is to have a configurable number of symbols spread
> equidistantly over the whole graph, regardless of the number or position
> of data-points.
>
> Does anyone have an idea how to achieve this?
>
Hi Timo,
I don't have time to program this at the moment, but the method isn't too hard, assuming that your line is defined by a series of x and y coordinates.

Define a function, e.g. equiPoints

Pass the x and y coordinate vectors and the distance between symbols

Start at the leftmost end of the line, recording the x/y coordinates

Calculate the length of successive segments until the cumulative length is >= the desired distance

Interpolate the x and y coordinates of the last segment to get the next position for a symbol

Add these x and y coordinates to the x and y coordinate vectors

Repeat until you reach the end of the line

Use the symbols function to plot the symbols at the coordinates you have calculated

Jim



R-help_at_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. Received on Tue 19 Apr 2011 - 08:37:53 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 19 Apr 2011 - 09:30:31 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive