Sometimes, when I plot multiple series using ggplot, two or more series are identical. The two identical series will not be identical within the plot: each one will have a different color. But one identical series will be plotted over the other. If I have three series, A, B, and C, and C is identical to B, I will see only two lines in the chart. I might try to figure out which of the two chart lines is representing two series by looking at the colors. This may work in simple cases, but with more than three series it is cumbersome and maybe impossible.
One solution to this problem might be doing point charts, that is, using geom_point() and use different shapes for the series. This might work, although awkwardly, for short series. With thousands of points in each series it does not help, as this example shows.
library(tidyverse)
ind <- seq.int(1000)
x <- (1 + runif(1000)/100) %>% cumprod %>% log()
y <- (1 + runif(1000)/200) %>% cumprod %>% log()
z <- y
df <- data.frame(Ind = ind, A = x, B = y, C = z)
dfp <- pivot_longer(df,
cols=c("A", "B", "C"),
names_to="Series")
p <- ggplot(data=dfp, aes(x=Ind, y = value,
col = Series,
shape = Series)) +
geom_point()
p
So here is my question: Is there a way to let users easily see which series have been plotted in the same line when some series are identical?
