0

I'm trying to create a scatter plot from a dataset that consists of NO3 measurements done in the field (F) and in the lab (G). I have successfully created the plot however I would like for the lab sample point in the graph to be slightly larger than the point for the field sample. I have not been successful or lucky at finding any code that has worked for me this far.

Also, I would like for the line joining the points to exclude the lab (G, red in the graph) and only join the field (F, black in the graph) samples. As you will see with the code below all points are connecting when creating the plot.

Please find attached a snippet of my dataset as well as the code I'm using for plotting the graph.

Any help will be greatly appreciated!

Data set

data<-structure(list(run = c(66, 66, 67, 68, 69), date = structure(c(18901,
18901, 18901, 18901, 18902), class = "Date"), sample = structure(c(1L,
2L, 1L, 1L, 1L), levels = c("F", "G"), class = "factor"), no3c = c(3.097800016,
2.99, 3.577300072, 3.960299969, 3.103699923), no2c = c(0.219300002,
0.2, 0.325800002, 0.311100006, 0.386000007)), row.names = 66:70, class = "data.frame")

Graph

plot <- ggplot(a1, aes(x = run, y = no2c, color = sample)) + 
  labs(title = expression(paste("C"))) + 
  xlab("Run number") +
  ylab(expression(paste("NO"[2], " (mg " ~L^-1*'', ")"))) + 
  geom_point(aes(shape = sample),size=2) +
  geom_line(aes(y=no2c, color="no2c"), color="black") + 
  scale_x_continuous(breaks=seq(65,70,1),limits = c(65,70)) +
  scale_y_continuous(breaks=seq(0,0.6,0.1), limits = c(0,0.6)) +
  theme_bw() + theme(panel.border = element_blank(), panel.grid.major = element_blank(),
                     panel.grid.minor = element_blank(), axis.line = element_line(colour = "black"),
                     axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1)) +
  theme(text = element_text(size=12),
        panel.border = element_rect(colour = "black", fill=NA, size=0.5),
        legend.position = "bottom", legend.title=element_text(size=12), legend.text = element_text(size=12),
        axis.title.y = element_text(size=12),
        plot.title = element_text(size=14, face="bold")) +
  scale_color_manual(name="Sample", 
                     labels=c("Analyser", "Grab"),
                     values = c("F"="black", "G"="red3"))

Let me know if further information is required for you to answer the question. Thank you so much for your time and help

Axeman
  • 32,068
  • 8
  • 81
  • 94
MGB
  • 5
  • 2
  • 1
    For the different sizes: `geom_point(aes(shape = sample, size = sample)) + scale_size_manual(values = c(F = 2, G = 4))`. For the line: `geom_line(aes(y=no2c, color="no2c"), color="black", data = subset(data, sample == 'F'))` . – Axeman Sep 26 '22 at 15:04

0 Answers0