I am very new to R and I have a question, how can I label this graphic? I already tried in several ways but I can't make them visible.
I need to add the label of each line are 2
A red, blue and green.
and I also need the example name to appear
ART50 inside the tag.
library(ggplot2)
library(tidyverse)
library(dplyr)
#dataset
name <- c("ART50","ART50","ART50","ART50")
subname <- c("BL19200025","BL19217046","BL19200024","SAMPLESKBP50")
lotacc <- c(1,1,1,1)
Started <-c(11.49,119.45,121.05,68.46)
Scrap <-c(0,0,0,0)
Finished<-c(11.49,119.45,121.05,68.46)
dataset <- data.frame(name,subname,lotacc,Started,Finished,Scrap)
#dataset%>%
ggplot(dataset)+ #Geom_Line de BLScrap
geom_line(mapping = aes(x = subname, y = Scrap*8, group = name),col = "Red",linetype = "dashed")+
geom_point(mapping = aes(x = subname, y = Scrap*8),col = "Red")+scale_y_continuous("Started & Finished",sec.axis = sec_axis(~ ./8, name = "BLScrap"))+
#Geom_Line de BLAmountStarted
geom_line(mapping = aes(x = subname, y = Started, group = name), col = "green")+
geom_point(mapping = aes(x = subname, y = Started, group = name), col = "Green")+
#Geom_Line de BLAmountFinished
geom_line(mapping = aes(x = subname, y = Finished, group = name), col = "Blue")+
geom_point(mapping = aes(x = subname, y = Finished), col = "Blue")+
#Style
theme_classic()+theme(axis.text.x=element_text(angle=-90, vjust=0.5, hjust=0))+
labs(title = "ART Results")
I enclose an example image.