I have plotted 2 lines on a graph using ggplot, specially using the "select" and "gather" tools to collapse the two line variables into key-value pairs using this method (solution 2 on here): https://www.datanovia.com/en/blog/how-to-create-a-ggplot-with-multiple-lines/
Everything works except I can't figure out how label the points of just ONE line using the "Desc" variable. The following code labels both lines with the Desc variable, but I only want to label the "elevation" line. Any ideas?
#preparing data
library("tidyverse")
df <- mydatacsv %>%
select(Meter, Stem_Height,Elevation,Desc) %>%
gather(key = "Legend", value = "value", -Meter,-Desc)
head(df,n=200)
# Visualization
ggplot(df, aes(x = Meter, y = value,label=Desc)) +
geom_line(aes(color = Legend)) +
scale_color_manual(values = c("green4","black")) +
geom_point(data=mydatacsv, aes(y = Stem_Height),color="green4")+
geom_point(data=mydatacsv, aes(y = Elevation),color="black")+
xlab("Distance (m)") +
ylab("Elevation (m)")+
geom_text_repel(max.overlaps=Inf,hjust=-0.1, angle=90)
I wanted two lines plotted, with plot point labels for just one line. Instead it is putting double-labels on the graph, one for each plot point on each line.