[R] plot many dfs in ggplot

lily li chocold12 at gmail.com
Wed Aug 3 00:21:16 CEST 2016

Another question is, if I want to shade the range between the maximum and
minimum values for daily or annual values, how to do it? Thanks again.

On Tue, Aug 2, 2016 at 12:50 PM, lily li <chocold12 at gmail.com> wrote:

> Hi all,
> I have another question. There are several dataframes, each has the same
> columns: time, varA, varB, varC, etc. If I want to plot time ~ varA of each
> dataframe, where different dataframe names use different colors. How to do
> this in ggplot? Thanks for your help.
> Right now, I tried to use the code below, but very laborious, and needs
> colors manually.
> fig1 = ggplot()+
>     geom_path(data=df1, aes(x=time, y= varA, color= 'df1'))+
>     geom_path(data=df2, aes(x=time, y= varA, color= 'df2'))+
>     geom_path(data=df3, aes(x=time, y= varA, color= 'df3'))+
>     ...
>     scale_color_manual('', limits=c('df1', 'df2', 'df3', ...),
> values=c('blue', red', 'green', ...))
> show(fig1)

	[[alternative HTML version deleted]]

More information about the R-help mailing list