I making an smoothed line plot which as 8 lines in R studio. I was able to define different line types such as solid, dashed,....etc,. But I want all lines to be solid with different shapes (such as diamond, star, circle, filled circle,...ect,.) as an line distinguisher. As it's a smoothened line I can't use normal geom_point layer to get the results.
My code is
custom_line_types <- c("solid", "dashed", "dotted", "dotdash", "longdash", "twodash", "22", "13")
my_theme <- theme_minimal() +
theme(
panel.border = element_rect(color = "black", fill=NA, size=1),
plot.background = element_rect(color = "black", fill = NA, size = 1),
plot.margin = margin(20, 20, 20, 20),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
axis.line = element_line(color="black"),
axis.text = element_text(color="black"),
axis.ticks = element_line(color="black"),
axis.ticks.length = unit(2.5, "mm"),
ggh4x.axis.ticks.length.minor = rel(0.5)
)
ggplot(df_plot, aes(x = z_position, y = mean_temp, linetype = file_name, color = file_name)) +
my_theme +
geom_smooth(method = "loess", span = 0.1, degree = 2, se = FALSE, size = 1) +
scale_linetype_manual(name = "Edcuts flow rate", values = custom_line_types) +
scale_color_manual(name = "Edcuts flow rate", values = rep("black", length(custom_line_types))) +
labs(x = "Distance", y = "Temperature in °C") +
theme(
legend.position = c(0.898, 0.14),
axis.text = element_text(size = 12),
axis.title = element_text(size = 14),
plot.title = element_text(size = 18),
legend.text = element_text(size = 11, face = "plain"),
legend.title = element_text(size = 14),
legend.background = element_rect(color = "black", size = 0.6, fill = NA)
) +
guides(color = guide_legend(ncol = 2), fill = guide_legend(ncol = 2)) +
scale_x_continuous(minor_breaks = seq(0, max(df_plot$z_position) + 10, by = 10), guide = guide_axis_minor()) +
scale_y_continuous(minor_breaks = seq(0, max(df_plot$mean_temp) + 10, by = 10), guide = guide_axis_minor())
Smoothened line with different shapes as an distinguisher like attached image