I'm trying to plot three different .csv columns, the 1st and 2nd as lines and the 3rd as points (only two points). I am a begineer in R and I have the following data
- data
- code
df = read.csv("conceptual_methodology.csv")
ggplot(df, aes(x=time, group=1))+
geom_line(aes(time, var_1, color = "var_1"), size = 1.2)+
geom_line(aes(time, var_2, color = "var_2"), size = 1.2)+
geom_point(aes(time, var_3, color = "red"), size = 3)+
scale_y_continuous(c(0.26, 0.3), seq(0, 0.3, 0.005))+
xlab("label_x")+
ylab("label_y")+
theme_bw()+
theme(axis.line = element_line(color = "black"),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.border = element_rect(color = "black"),
axis.ticks.x=element_blank(),
axis.text.x=element_blank(),
panel.background = element_blank())
The outcome is the following image:
Obviously, my code is not brilliant and I have the following problems with the result:
- ylab does not appear
- numbers in x axis do not appear
- I don't understand why everything appears as line and point in the legend, and not var_1 & var_2 just lines and var_3 just point.
- Why y axis stops at 0.295 and not 0.3 as specified in scale_y_continuous.
- How can I change the colors of the lines and points without changing the names in the legend. For example, when I put color="red" in geom_point the name of the series becomes red in the legend.
Can someone please fix my code?