I am trying to combine the shape
and colour
legends combined in the plot but all I can do is combine colour
and linetype
.
sample data:
> dput(sample_n(ALL_Spans, 10))
structure(list(UG = c("100", "124", "108", "92", "124", "84",
"100", "100", "124", "84"), S = c(12, 12, 12, 12, 12, 12, 12,
12, 12, 12), EQ = c("Cai", "AASHTO LRFD", "Suksawang & Nassif",
"AASHTO LRFD", "Modified Henry", "Modified Henry", "Analytical Data",
"Rigid Rotation", "Rigid Rotation", "Rigid Rotation"), DF = c(0.818313323177077,
1.01028571424963, 0.741281190719393, 1.08244897959184, 0.858545454545455,
0.858545454545455, 0.789710362673591, 0.71825, 0.926666666666667,
0.926666666666667), Girder = c("Exterior Girder", "Exterior Girder",
"Exterior Girder", "Interior Girder", "Interior Girder", "Exterior Girder",
"Exterior Girder", "Interior Girder", "Exterior Girder", "Exterior Girder"
), Type = c("Moment LLDF", "Shear LLDF", "Moment LLDF", "Shear LLDF",
"Moment LLDF", "Moment LLDF", "Moment LLDF", "Moment LLDF", "Moment LLDF",
"Moment LLDF"), L = c(240L, 300L, 260L, 220L, 300L, 200L, 240L,
240L, 300L, 200L), group = c("Cai 12", "AASHTO LRFD 12", "Suksawang & Nassif 12",
"AASHTO LRFD 12", "Modified Henry 12", "Modified Henry 12", "Analytical Data 12",
"Rigid Rotation 12", "Rigid Rotation 12", "Rigid Rotation 12"
)), row.names = c(NA, -10L), class = "data.frame")
code for the plot:
b <- ggplot(data = ALL_Spans, aes(x = L, y = DF, colour = EQ)) +
geom_point(aes(shape = EQ), stroke = 0.2, size = 2) +
geom_line(size = 0.2, linetype = "dotted") +
scale_shape_manual(values = c(0,19,3,2,4,5,6,8)) + theme_classic() +
scale_colour_manual(values = c("black", "red", rep("black",6))) +
scale_x_continuous(breaks = seq(200,300,20), limits = c(200,300)) +
labs(x = "x", y = element_blank(), shape = element_blank()) +
theme(legend.title.align = 0.5, legend.position = "bottom",
axis.text = element_text(size=8, colour="black"),
axis.title.x = element_text(size=8, colour="black"),
axis.line = element_blank(),
axis.ticks = element_line(colour = "black", size = 0.2),
legend.text = element_text(size=8, margin = margin(-10,5,-10,-4.5)),
legend.title = element_text(size=8, margin = margin(-10,1.5,-10,0)),
legend.spacing.x = unit(0.1, 'cm'), legend.spacing.y = unit(0, 'cm'),
legend.background = element_blank(), panel.margin.y = unit(0.3, "lines"),
legend.box.background = element_rect(color = "black", size = 0.2)) +
guides(shape = guide_legend(nrow=2,byrow=TRUE), linetype = FALSE,
color = guide_legend(nrow = 2, byrow = TRUE)) +
facet_grid(Type~Girder)
the current plot is
the desired plot would be