legend adding in ggplot with uncertainties
I am new R user. I tried to add legend of mean data of df_summary1 and df_summary2 with title "RCP4.5" and "RCP8.5" in my ggplot but fail. Can any one help me on this. Thanks in advance.
ggplot()+
geom_line(data=df_tidy1, aes(x=date, y=Ratio, group=Cell), color="grey") +
geom_line(data=df_tidy2, aes(x=date, y=Ratio, group=Cell), color="grey")+
geom_line(data = df_summary1, aes(x = date, y=mean), color = "red") +
geom_line(data = df_summary2, aes(x = date, y=mean), color = "blue")+
geom_ribbon(data =df_summary1, aes(x= date, ymin=CI_lower, ymax=CI_upper) ,fill="blue", alpha=0.2)+
geom_ribbon(data =df_summary2,aes(x= date, ymin=CI_lower, ymax=CI_upper) ,fill="grey", alpha=0.2)+
xlab("data") + ylab("Average temperature")
Here is the graph
the df_tidy1 look like:
data.frame(stringsAsFactors=FALSE,
date = c("1980-01-01", "1981-01-01", "1982-01-01", "1983-01-01",
"1984-01-01", "1985-01-01"),
Cell = c("Acsess.4.5", "Acsess.4.5", "Acsess.4.5", "Acsess.4.5",
"Acsess.4.5", "Acsess.4.5"),
Ratio = c(29.8715846994536, 29.5917808219178, 29.7479452054795,
30.2602739726027, 29.266393442623, 29.5342465753425)
)
the df_summary look like
data.frame(
date = c("1980-01-01", "1981-01-01", "1982-01-01", "1983-01-01",
"1984-01-01", "1985-01-01"),
n = c("5", "5", "5", "5", "5", "5"),
mean = c("29.8715846994536", "29.5917808219178", "29.7479452054795",
"30.2602739726027", "29.266393442623", "29.5342465753425"),
sd = c("0", "0", "0", "0", "0", "0"),
sem = c("0", "0", "0", "0", "0", "0"),
CI_lower = c("29.8715846994536", "29.5917808219178", "29.7479452054795",
"30.2602739726027", "29.266393442623", "29.5342465753425"),
CI_upper = c("29.8715846994536", "29.5917808219178", "29.7479452054795",
"30.2602739726027", "29.266393442623", "29.5342465753425")
)
r ggplot2
add a comment |
I am new R user. I tried to add legend of mean data of df_summary1 and df_summary2 with title "RCP4.5" and "RCP8.5" in my ggplot but fail. Can any one help me on this. Thanks in advance.
ggplot()+
geom_line(data=df_tidy1, aes(x=date, y=Ratio, group=Cell), color="grey") +
geom_line(data=df_tidy2, aes(x=date, y=Ratio, group=Cell), color="grey")+
geom_line(data = df_summary1, aes(x = date, y=mean), color = "red") +
geom_line(data = df_summary2, aes(x = date, y=mean), color = "blue")+
geom_ribbon(data =df_summary1, aes(x= date, ymin=CI_lower, ymax=CI_upper) ,fill="blue", alpha=0.2)+
geom_ribbon(data =df_summary2,aes(x= date, ymin=CI_lower, ymax=CI_upper) ,fill="grey", alpha=0.2)+
xlab("data") + ylab("Average temperature")
Here is the graph
the df_tidy1 look like:
data.frame(stringsAsFactors=FALSE,
date = c("1980-01-01", "1981-01-01", "1982-01-01", "1983-01-01",
"1984-01-01", "1985-01-01"),
Cell = c("Acsess.4.5", "Acsess.4.5", "Acsess.4.5", "Acsess.4.5",
"Acsess.4.5", "Acsess.4.5"),
Ratio = c(29.8715846994536, 29.5917808219178, 29.7479452054795,
30.2602739726027, 29.266393442623, 29.5342465753425)
)
the df_summary look like
data.frame(
date = c("1980-01-01", "1981-01-01", "1982-01-01", "1983-01-01",
"1984-01-01", "1985-01-01"),
n = c("5", "5", "5", "5", "5", "5"),
mean = c("29.8715846994536", "29.5917808219178", "29.7479452054795",
"30.2602739726027", "29.266393442623", "29.5342465753425"),
sd = c("0", "0", "0", "0", "0", "0"),
sem = c("0", "0", "0", "0", "0", "0"),
CI_lower = c("29.8715846994536", "29.5917808219178", "29.7479452054795",
"30.2602739726027", "29.266393442623", "29.5342465753425"),
CI_upper = c("29.8715846994536", "29.5917808219178", "29.7479452054795",
"30.2602739726027", "29.266393442623", "29.5342465753425")
)
r ggplot2
Welcome to Stack Overflow! Could you make your problem reproducible by sharing a sample of your data so others can help (please do not usestr()
,head()
or screenshot)? You can use thereprex
anddatapasta
packages to assist you with that. See also Help me Help you & How to make a great R reproducible example?
– Tung
Nov 16 '18 at 4:35
yes I already change some but not sure it correct. Thanks for your comment
– Trang Pham
Nov 16 '18 at 7:45
use bind_rows to combine tidy1 & tidy2 into a single dataframe and then plot with a single call to geom_line.
– Richard Telford
Nov 16 '18 at 8:48
add a comment |
I am new R user. I tried to add legend of mean data of df_summary1 and df_summary2 with title "RCP4.5" and "RCP8.5" in my ggplot but fail. Can any one help me on this. Thanks in advance.
ggplot()+
geom_line(data=df_tidy1, aes(x=date, y=Ratio, group=Cell), color="grey") +
geom_line(data=df_tidy2, aes(x=date, y=Ratio, group=Cell), color="grey")+
geom_line(data = df_summary1, aes(x = date, y=mean), color = "red") +
geom_line(data = df_summary2, aes(x = date, y=mean), color = "blue")+
geom_ribbon(data =df_summary1, aes(x= date, ymin=CI_lower, ymax=CI_upper) ,fill="blue", alpha=0.2)+
geom_ribbon(data =df_summary2,aes(x= date, ymin=CI_lower, ymax=CI_upper) ,fill="grey", alpha=0.2)+
xlab("data") + ylab("Average temperature")
Here is the graph
the df_tidy1 look like:
data.frame(stringsAsFactors=FALSE,
date = c("1980-01-01", "1981-01-01", "1982-01-01", "1983-01-01",
"1984-01-01", "1985-01-01"),
Cell = c("Acsess.4.5", "Acsess.4.5", "Acsess.4.5", "Acsess.4.5",
"Acsess.4.5", "Acsess.4.5"),
Ratio = c(29.8715846994536, 29.5917808219178, 29.7479452054795,
30.2602739726027, 29.266393442623, 29.5342465753425)
)
the df_summary look like
data.frame(
date = c("1980-01-01", "1981-01-01", "1982-01-01", "1983-01-01",
"1984-01-01", "1985-01-01"),
n = c("5", "5", "5", "5", "5", "5"),
mean = c("29.8715846994536", "29.5917808219178", "29.7479452054795",
"30.2602739726027", "29.266393442623", "29.5342465753425"),
sd = c("0", "0", "0", "0", "0", "0"),
sem = c("0", "0", "0", "0", "0", "0"),
CI_lower = c("29.8715846994536", "29.5917808219178", "29.7479452054795",
"30.2602739726027", "29.266393442623", "29.5342465753425"),
CI_upper = c("29.8715846994536", "29.5917808219178", "29.7479452054795",
"30.2602739726027", "29.266393442623", "29.5342465753425")
)
r ggplot2
I am new R user. I tried to add legend of mean data of df_summary1 and df_summary2 with title "RCP4.5" and "RCP8.5" in my ggplot but fail. Can any one help me on this. Thanks in advance.
ggplot()+
geom_line(data=df_tidy1, aes(x=date, y=Ratio, group=Cell), color="grey") +
geom_line(data=df_tidy2, aes(x=date, y=Ratio, group=Cell), color="grey")+
geom_line(data = df_summary1, aes(x = date, y=mean), color = "red") +
geom_line(data = df_summary2, aes(x = date, y=mean), color = "blue")+
geom_ribbon(data =df_summary1, aes(x= date, ymin=CI_lower, ymax=CI_upper) ,fill="blue", alpha=0.2)+
geom_ribbon(data =df_summary2,aes(x= date, ymin=CI_lower, ymax=CI_upper) ,fill="grey", alpha=0.2)+
xlab("data") + ylab("Average temperature")
Here is the graph
the df_tidy1 look like:
data.frame(stringsAsFactors=FALSE,
date = c("1980-01-01", "1981-01-01", "1982-01-01", "1983-01-01",
"1984-01-01", "1985-01-01"),
Cell = c("Acsess.4.5", "Acsess.4.5", "Acsess.4.5", "Acsess.4.5",
"Acsess.4.5", "Acsess.4.5"),
Ratio = c(29.8715846994536, 29.5917808219178, 29.7479452054795,
30.2602739726027, 29.266393442623, 29.5342465753425)
)
the df_summary look like
data.frame(
date = c("1980-01-01", "1981-01-01", "1982-01-01", "1983-01-01",
"1984-01-01", "1985-01-01"),
n = c("5", "5", "5", "5", "5", "5"),
mean = c("29.8715846994536", "29.5917808219178", "29.7479452054795",
"30.2602739726027", "29.266393442623", "29.5342465753425"),
sd = c("0", "0", "0", "0", "0", "0"),
sem = c("0", "0", "0", "0", "0", "0"),
CI_lower = c("29.8715846994536", "29.5917808219178", "29.7479452054795",
"30.2602739726027", "29.266393442623", "29.5342465753425"),
CI_upper = c("29.8715846994536", "29.5917808219178", "29.7479452054795",
"30.2602739726027", "29.266393442623", "29.5342465753425")
)
r ggplot2
r ggplot2
edited Nov 16 '18 at 8:46
Richard Telford
5,97752436
5,97752436
asked Nov 16 '18 at 3:12
Trang PhamTrang Pham
84
84
Welcome to Stack Overflow! Could you make your problem reproducible by sharing a sample of your data so others can help (please do not usestr()
,head()
or screenshot)? You can use thereprex
anddatapasta
packages to assist you with that. See also Help me Help you & How to make a great R reproducible example?
– Tung
Nov 16 '18 at 4:35
yes I already change some but not sure it correct. Thanks for your comment
– Trang Pham
Nov 16 '18 at 7:45
use bind_rows to combine tidy1 & tidy2 into a single dataframe and then plot with a single call to geom_line.
– Richard Telford
Nov 16 '18 at 8:48
add a comment |
Welcome to Stack Overflow! Could you make your problem reproducible by sharing a sample of your data so others can help (please do not usestr()
,head()
or screenshot)? You can use thereprex
anddatapasta
packages to assist you with that. See also Help me Help you & How to make a great R reproducible example?
– Tung
Nov 16 '18 at 4:35
yes I already change some but not sure it correct. Thanks for your comment
– Trang Pham
Nov 16 '18 at 7:45
use bind_rows to combine tidy1 & tidy2 into a single dataframe and then plot with a single call to geom_line.
– Richard Telford
Nov 16 '18 at 8:48
Welcome to Stack Overflow! Could you make your problem reproducible by sharing a sample of your data so others can help (please do not use
str()
, head()
or screenshot)? You can use the reprex
and datapasta
packages to assist you with that. See also Help me Help you & How to make a great R reproducible example?– Tung
Nov 16 '18 at 4:35
Welcome to Stack Overflow! Could you make your problem reproducible by sharing a sample of your data so others can help (please do not use
str()
, head()
or screenshot)? You can use the reprex
and datapasta
packages to assist you with that. See also Help me Help you & How to make a great R reproducible example?– Tung
Nov 16 '18 at 4:35
yes I already change some but not sure it correct. Thanks for your comment
– Trang Pham
Nov 16 '18 at 7:45
yes I already change some but not sure it correct. Thanks for your comment
– Trang Pham
Nov 16 '18 at 7:45
use bind_rows to combine tidy1 & tidy2 into a single dataframe and then plot with a single call to geom_line.
– Richard Telford
Nov 16 '18 at 8:48
use bind_rows to combine tidy1 & tidy2 into a single dataframe and then plot with a single call to geom_line.
– Richard Telford
Nov 16 '18 at 8:48
add a comment |
1 Answer
1
active
oldest
votes
You didn't provide df_tidy2
and df_summary2
but this should give you a good start
library(tidyverse)
ggplot() +
geom_line(data = df_tidy1, aes(x = date, y = Ratio, group = Cell), color = "grey") +
# geom_line(data = df_tidy2, aes(x = date, y = Ratio, group = Cell), color = "grey") +
geom_line(data = df_summary1, aes(x = date, y = mean, color = "RCP4.5")) +
# geom_line(data = df_summary2, aes(x = date, y = mean, color = "blue")) +
geom_ribbon(data = df_summary1, aes(x = date, ymin = CI_lower, ymax = CI_upper),
fill = "blue", alpha = 0.2) +
# geom_ribbon(data = df_summary2, aes(x = date, ymin = CI_lower, ymax = CI_upper), fill = "grey", alpha = 0.2) +
xlab("Date") +
ylab("Average temperature") +
scale_color_manual("Legend", values = c("blue")) +
scale_x_date(expand = c(0, 0), date_breaks = '18 months', date_labels = "%b-%Y") +
theme_classic(base_size = 14)
Created on 2018-11-16 by the reprex package (v0.2.1.9000)
Also relevant: stackoverflow.com/a/49957519 & stackoverflow.com/a/49377292
– Tung
Nov 16 '18 at 17:23
1
This might be relevant too: stackoverflow.com/questions/21861617/…
– iouraich
Nov 16 '18 at 18:28
1
Thank you so much for your help
– Trang Pham
Nov 17 '18 at 14:17
1
@Tung: yep, done. Thank for your suggestion
– Trang Pham
Nov 18 '18 at 8:52
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53330895%2flegend-adding-in-ggplot-with-uncertainties%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You didn't provide df_tidy2
and df_summary2
but this should give you a good start
library(tidyverse)
ggplot() +
geom_line(data = df_tidy1, aes(x = date, y = Ratio, group = Cell), color = "grey") +
# geom_line(data = df_tidy2, aes(x = date, y = Ratio, group = Cell), color = "grey") +
geom_line(data = df_summary1, aes(x = date, y = mean, color = "RCP4.5")) +
# geom_line(data = df_summary2, aes(x = date, y = mean, color = "blue")) +
geom_ribbon(data = df_summary1, aes(x = date, ymin = CI_lower, ymax = CI_upper),
fill = "blue", alpha = 0.2) +
# geom_ribbon(data = df_summary2, aes(x = date, ymin = CI_lower, ymax = CI_upper), fill = "grey", alpha = 0.2) +
xlab("Date") +
ylab("Average temperature") +
scale_color_manual("Legend", values = c("blue")) +
scale_x_date(expand = c(0, 0), date_breaks = '18 months', date_labels = "%b-%Y") +
theme_classic(base_size = 14)
Created on 2018-11-16 by the reprex package (v0.2.1.9000)
Also relevant: stackoverflow.com/a/49957519 & stackoverflow.com/a/49377292
– Tung
Nov 16 '18 at 17:23
1
This might be relevant too: stackoverflow.com/questions/21861617/…
– iouraich
Nov 16 '18 at 18:28
1
Thank you so much for your help
– Trang Pham
Nov 17 '18 at 14:17
1
@Tung: yep, done. Thank for your suggestion
– Trang Pham
Nov 18 '18 at 8:52
add a comment |
You didn't provide df_tidy2
and df_summary2
but this should give you a good start
library(tidyverse)
ggplot() +
geom_line(data = df_tidy1, aes(x = date, y = Ratio, group = Cell), color = "grey") +
# geom_line(data = df_tidy2, aes(x = date, y = Ratio, group = Cell), color = "grey") +
geom_line(data = df_summary1, aes(x = date, y = mean, color = "RCP4.5")) +
# geom_line(data = df_summary2, aes(x = date, y = mean, color = "blue")) +
geom_ribbon(data = df_summary1, aes(x = date, ymin = CI_lower, ymax = CI_upper),
fill = "blue", alpha = 0.2) +
# geom_ribbon(data = df_summary2, aes(x = date, ymin = CI_lower, ymax = CI_upper), fill = "grey", alpha = 0.2) +
xlab("Date") +
ylab("Average temperature") +
scale_color_manual("Legend", values = c("blue")) +
scale_x_date(expand = c(0, 0), date_breaks = '18 months', date_labels = "%b-%Y") +
theme_classic(base_size = 14)
Created on 2018-11-16 by the reprex package (v0.2.1.9000)
Also relevant: stackoverflow.com/a/49957519 & stackoverflow.com/a/49377292
– Tung
Nov 16 '18 at 17:23
1
This might be relevant too: stackoverflow.com/questions/21861617/…
– iouraich
Nov 16 '18 at 18:28
1
Thank you so much for your help
– Trang Pham
Nov 17 '18 at 14:17
1
@Tung: yep, done. Thank for your suggestion
– Trang Pham
Nov 18 '18 at 8:52
add a comment |
You didn't provide df_tidy2
and df_summary2
but this should give you a good start
library(tidyverse)
ggplot() +
geom_line(data = df_tidy1, aes(x = date, y = Ratio, group = Cell), color = "grey") +
# geom_line(data = df_tidy2, aes(x = date, y = Ratio, group = Cell), color = "grey") +
geom_line(data = df_summary1, aes(x = date, y = mean, color = "RCP4.5")) +
# geom_line(data = df_summary2, aes(x = date, y = mean, color = "blue")) +
geom_ribbon(data = df_summary1, aes(x = date, ymin = CI_lower, ymax = CI_upper),
fill = "blue", alpha = 0.2) +
# geom_ribbon(data = df_summary2, aes(x = date, ymin = CI_lower, ymax = CI_upper), fill = "grey", alpha = 0.2) +
xlab("Date") +
ylab("Average temperature") +
scale_color_manual("Legend", values = c("blue")) +
scale_x_date(expand = c(0, 0), date_breaks = '18 months', date_labels = "%b-%Y") +
theme_classic(base_size = 14)
Created on 2018-11-16 by the reprex package (v0.2.1.9000)
You didn't provide df_tidy2
and df_summary2
but this should give you a good start
library(tidyverse)
ggplot() +
geom_line(data = df_tidy1, aes(x = date, y = Ratio, group = Cell), color = "grey") +
# geom_line(data = df_tidy2, aes(x = date, y = Ratio, group = Cell), color = "grey") +
geom_line(data = df_summary1, aes(x = date, y = mean, color = "RCP4.5")) +
# geom_line(data = df_summary2, aes(x = date, y = mean, color = "blue")) +
geom_ribbon(data = df_summary1, aes(x = date, ymin = CI_lower, ymax = CI_upper),
fill = "blue", alpha = 0.2) +
# geom_ribbon(data = df_summary2, aes(x = date, ymin = CI_lower, ymax = CI_upper), fill = "grey", alpha = 0.2) +
xlab("Date") +
ylab("Average temperature") +
scale_color_manual("Legend", values = c("blue")) +
scale_x_date(expand = c(0, 0), date_breaks = '18 months', date_labels = "%b-%Y") +
theme_classic(base_size = 14)
Created on 2018-11-16 by the reprex package (v0.2.1.9000)
answered Nov 16 '18 at 8:57
TungTung
9,89122844
9,89122844
Also relevant: stackoverflow.com/a/49957519 & stackoverflow.com/a/49377292
– Tung
Nov 16 '18 at 17:23
1
This might be relevant too: stackoverflow.com/questions/21861617/…
– iouraich
Nov 16 '18 at 18:28
1
Thank you so much for your help
– Trang Pham
Nov 17 '18 at 14:17
1
@Tung: yep, done. Thank for your suggestion
– Trang Pham
Nov 18 '18 at 8:52
add a comment |
Also relevant: stackoverflow.com/a/49957519 & stackoverflow.com/a/49377292
– Tung
Nov 16 '18 at 17:23
1
This might be relevant too: stackoverflow.com/questions/21861617/…
– iouraich
Nov 16 '18 at 18:28
1
Thank you so much for your help
– Trang Pham
Nov 17 '18 at 14:17
1
@Tung: yep, done. Thank for your suggestion
– Trang Pham
Nov 18 '18 at 8:52
Also relevant: stackoverflow.com/a/49957519 & stackoverflow.com/a/49377292
– Tung
Nov 16 '18 at 17:23
Also relevant: stackoverflow.com/a/49957519 & stackoverflow.com/a/49377292
– Tung
Nov 16 '18 at 17:23
1
1
This might be relevant too: stackoverflow.com/questions/21861617/…
– iouraich
Nov 16 '18 at 18:28
This might be relevant too: stackoverflow.com/questions/21861617/…
– iouraich
Nov 16 '18 at 18:28
1
1
Thank you so much for your help
– Trang Pham
Nov 17 '18 at 14:17
Thank you so much for your help
– Trang Pham
Nov 17 '18 at 14:17
1
1
@Tung: yep, done. Thank for your suggestion
– Trang Pham
Nov 18 '18 at 8:52
@Tung: yep, done. Thank for your suggestion
– Trang Pham
Nov 18 '18 at 8:52
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53330895%2flegend-adding-in-ggplot-with-uncertainties%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Welcome to Stack Overflow! Could you make your problem reproducible by sharing a sample of your data so others can help (please do not use
str()
,head()
or screenshot)? You can use thereprex
anddatapasta
packages to assist you with that. See also Help me Help you & How to make a great R reproducible example?– Tung
Nov 16 '18 at 4:35
yes I already change some but not sure it correct. Thanks for your comment
– Trang Pham
Nov 16 '18 at 7:45
use bind_rows to combine tidy1 & tidy2 into a single dataframe and then plot with a single call to geom_line.
– Richard Telford
Nov 16 '18 at 8:48