I have a dataframe with useful data that I need to plot. The dataframe includes some coordinates that I would like plotted automatically using ggplot, rather then manually inputting the coordinates received from the results.
I seem to recall a simple addition to the ggplot function that would allow this, but am not bringing anything to mind.
Below is example code that plots some random data, but highlights some useful coordinates found within the dataframe.
a <- list(1.5, 100, 3.5)
b <- list(1.5, 105, 2.5)
c <- list(1.5, 205, 1.5)
d <- as.data.frame(rbind(a,b,c)) #test dataframe with useful information
time <- seq.int(0,419.5,0.5) #x-axis
set.seed(1)
pyro <- rnorm(840)
ggplot(data=d, aes(x=time,y=pyro)) +
geom_point(alpha=1/4) +
geom_point(x=100, y=1.5, color="red", size=5) +
geom_point(y=1.5, alpha=.10, color="red", size=.25)
I would like to have the coordinates "automatically" be inserted rather than manually looking them up, I tried to do this with the following code:
ggplot(data=d, aes(x=time,y=pyro)) +
geom_point(alpha=1/4) +
geom_point(x=d[1,2], y=d[1,1], color="red", size=5) +
geom_point(y=d[1,1], alpha=.10, color="red", size=.25)
This however doesn't seem to be allowed.
Any help much appreciated, thanks.