0

Basically, I want to make a graph that shows where different "analysts" chose a certain point on the graph.

This is what the base graph looks like This is what the base graph looks like.

This is what I want to produce This is what I want to produce.
I have a separate dataframe called sum_data that summarizes the time choices made by each analyst. It looks like this. The following is the code used to create the plot:

gqplot <- ggplot(Qdata,
                aes(x = date, 
                    y = cfs))+
  labs(#title = paste(watershedID,"_",event),
       x = "Date",
       y = "Flow [cfs]")+
  geom_line(colour = "#000099")+

# Show plot 
gqplot 
tjebo
  • 21,977
  • 7
  • 58
  • 94
Paul
  • 3
  • 1

1 Answers1

0

Hey what you need is a data.frame that contains the choices of those 2 people (like your sum_data) and then use geom_point().

Here is an example. I made up data and code etc because you didn't provide a completely reproducible example.

# Library
library(ggplot2)

# Seed for exact reproducibility
set.seed(20210307)

# Main data frame
main_data      <- data.frame(x = 1:10, y = rnorm(10))

# Analyst data frame
analyst_choice <- data.frame(x = c(2, 3), y = main_data[2:3, 'y'], analyst = c('John', 'Paul'))

# Create plot
ggplot(main_data, aes(x = x, y = y)) + 
  geom_line() + 
  geom_point(data = analyst_choice, aes(x = x, y = y, colour = analyst), size = 10, shape = 4)

That's what this code produces:

enter image description here

JAQuent
  • 1,137
  • 11
  • 25