I have a source of data that has the following structure: timestamp, value, category. I visualize it using ggplot:
df %>% ggplot(aes(x=timestamp, y=value, col=category)) + geom_line()
While it works, there is a problem, namely, the mapping between category values and colors is not consistent from time to time.
I've looked at solution offered in How to assign colors to categorical variables in ggplot2 that have stable mapping?
but it doesn't seem to help me as I don't have a full list of all factor levels upfront. It has hundreds of possible values, and I have to wrap up most of them into an 'others' level to make the graph legible.
It may appear as an insignificant problem. However, some of the factor levels are very common and appear in every data snapshot. Therefore it's confusing when every time they appear in a different color.
Any suggestions would be greatly appreciated.
Best regards, Nikolai