Tribo Laboy
2008-Feb-25 04:01 UTC
[R] Plotting series marked with a symbol on every nth data point, preferably in ggplot...
Hello! I am working with signals and a plot of several signals on the same axes can get quite messy. With lines that are very fractured, distinction by only the linestyle is not very clear. If I add symbols to the plot however, there are so many symbols, that they overplot and the whole plot is unreadable once again. I am looking for advice on how to make a plot with continuous lines and symbols appearing at every nth point. An example of this problem and a solution in SAS can be found here: www2.sas.com/proceedings/sugi26/p072-26.pdf The obvious solution would be to extract the n-th point from the dataset and overplot as a new line with symbols, but this does not change the legend, does it? How can I then have a line+symbol in the legend represent my curve? Now, ideally I would prefer a solution in ggplot, because of the ease of plotting and changing the plot labels and other properties. However, I remember, Hadley mentioned that he is still working on a new version to have combined line+symbol plots, and probably he hasn't finished that yet. So any advice is welcome. Regards, TL PS. I did RTFM and I am not posting code, because at this time I expect a general outline how to do it and what commands to lookup, not code.
Gabor Grothendieck
2008-Feb-25 05:05 UTC
[R] Plotting series marked with a symbol on every nth data point, preferably in ggplot...
Try this: pch <- c("+", ""); lwd <- 1 plot(1:10, type = "o", pch = pch, lwd = lwd) legend("topleft", legend = "data", pch = pch, lwd = lwd) On Sun, Feb 24, 2008 at 11:01 PM, Tribo Laboy <tribolaboy at gmail.com> wrote:> Hello! > > I am working with signals and a plot of several signals on the same > axes can get quite messy. With lines that are very fractured, > distinction by only the linestyle is not very clear. If I add symbols > to the plot however, there are so many symbols, that they overplot and > the whole plot is unreadable once again. I am looking for advice on > how to make a plot with continuous lines and symbols appearing at > every nth point. An example of this problem and a solution in SAS can > be found here: > www2.sas.com/proceedings/sugi26/p072-26.pdf > > The obvious solution would be to extract the n-th point from the > dataset and overplot as a new line with symbols, but this does not > change the legend, does it? How can I then have a line+symbol in the > legend represent my curve? > > Now, ideally I would prefer a solution in ggplot, because of the ease > of plotting and changing the plot labels and other properties. > However, I remember, Hadley mentioned that he is still working on a > new version to have combined line+symbol plots, and probably he hasn't > finished that yet. So any advice is welcome. > > Regards, > > TL > > PS. I did RTFM and I am not posting code, because at this time I > expect a general outline how to do it and what commands to lookup, not > code. > > ______________________________________________ > 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. >