I get 2 different legends one for shape and one for color. I've read: Combine legends for color and shape into a single legend already but I have no clue how to combine a color/shape identity together.
My Data:
It calls Vergleich2
My code:
Vergleich2 <- data.frame(
list(
RH = c(4.4, 70.81, 89.74, 98.21, 99.45, 100.3, 101.16, 101.83, 103.46, 103.65, 103.9, 33.37, 32.26, 50.39, 75.65, 81.54, 86.58, 91.88, 94.1, 96.41, 98.52, 99.93, 101.45, 77.09, 84.51, 92.15, 94.61, 96.22, 97.36, 98.85, 98.95, 98.74, 99.34, 100.07, 101.06, 102.45, 103.04),
max = c(0, 0.0262005491707849,
0.0960002914076637, 0.26123554979527, 0.299421329851762, 0.362190635901956, 0.452267730725373, 0.60803295055093, 0.958096790371026, 0.995440372287362, 1, 0.0191985206504361, 0, 0.0444427600652313, 0.0676200802520531, 0.0922989569990268, 0.112052964622176, 0.182215180712429, 0.248659241123121, 0.327097853193048, 0.496708233033155, 0.627302705113058, 1, 0.515522981617377, 0.585402158506993, 0.762678213109326, 0.920738889764711, 0.836214001953324, 0.871654063266438, 0.908503395902539, 0.825786584233689, 0.875522664077668, 0.831158954459146, 0.831533205795933, 0.893700430247523, 1.00803637031109,
1), letzte = c(0, 0.0171373807524096, 0.0818334694345387, 0.239981280241844, 0.280068579568638, 0.345939316999413, 0.434432925347285, 0.611502937955804, 0.964279264750348, 1.00834862405373, 1, 0.00678220086610785, 0, -0.00307024455552525, 0.0255053593718935, 0.0748980985479396, 0.0890155980480638, 0.153017148428967, 0.187262260262659, 0.306449913424004,
0.454599256084893, 0.614943073105356, 1, 0.527873986434174, 0.593334258062775, 0.768834444991388, 1.21440714508987, 0.847592976104216, 0.892496700707447, 0.917439391188656, 0.834935302471757, 0.840806889095709, 0.823590477107656,
0.834511976098586, 0.912778381850167, 1.00642363306524, 1)))
Region1_plot <- ggplot()+
geom_point(data=Vergleich2[c(1:11),], mapping=aes(x=RH,y=max,col="red",shape=19))+
geom_point(data=Vergleich2[c(1:11),], mapping=aes(x=RH,y=letzte, col="blue",shape=19))+
geom_point(data=Vergleich2[c(12:13),], mapping=aes(x=RH,y=max,col="red",shape=3))+
geom_point(data=Vergleich2[c(12:13),], mapping=aes(x=RH,y=letzte, col="blue",shape=3))+
geom_point(data=Vergleich2[c(14:23),], mapping=aes(x=RH,y=max,col="red",shape=6))+
geom_point(data=Vergleich2[c(14:23),], mapping=aes(x=RH,y=letzte, col="blue",shape=6))+
scale_color_identity("", guide="legend", breaks=c("red","blue"),labels=c("Incr.1","Decr.1"))+
scale_shape_identity("", guide = "legend", breaks=c(19,3,6), labels=c("Incr.1","Decr.1", "Incr.2"))+
labs(title = "Relative Wasseraufnahme Isopren SOA #10 (RH)", title.position="center")+
ylab("Norm. Optical Density [-]")+
xlab("RH [%]")+
coord_cartesian(xlim = c(0, 100))+
scale_x_continuous(breaks=c(seq(0,120, 4)))+
theme(axis.text = element_text(size = 15),
axis.title = element_text(size=15),
plot.title = element_text(hjust = 0.5),
legend.title = element_text(size=0),
legend.text= element_text(size=15),
legend.background = element_rect(),
legend.position = c(0.095,0.9),
title = element_text(size=20))
print(Region1_plot)
Thx for your help!!