I know that it is possible to put two scatterplots onto one plot in ggplot2
, but I also need to put an arrow between the relevant points.
For example, if I have the following data.frame
:
SPEAKER <- c("A","A","B","B")
VOWEL <- c("ej","ow","ej","ow")
MB_F1_ONGLIDE <- c(423.88,533.297,465.796,532.118)
MB_F2_ONGLIDE <- c(1847.428,962.485,1815.381,1058.883)
MB_F1_OFFGLIDE <- c(404.827,480.176,423.381,522.727)
MB_F2_OFFGLIDE <- c(1885.349,911.669,1887.392,971.168)
data <- data.frame(SPEAKER,VOWEL,MB_F1_ONGLIDE,MB_F2_ONGLIDE,MB_F1_OFFGLIDE,MB_F2_OFFGLIDE)
I know that I can make two scatterplots appear on the same plot like this:
plot <- ggplot(data,aes(x = MB_F2_ONGLIDE,y = MB_F1_ONGLIDE,color = SPEAKER,label = VOWEL)) +
geom_text(aes(x = MB_F2_ONGLIDE,y = MB_F1_ONGLIDE)) +
geom_text(aes(x = MB_F2_OFFGLIDE,y = MB_F1_OFFGLIDE)) +
scale_x_reverse() +
scale_y_reverse()
Which produces:
But what I want is something like:
That is, I want something that draws an arrow from the MB_F1_ONGLIDE
value to the MB_F1_OFFGLIDE
value and something that draws an arrow from the MB_F2_ONGLIDE
value to the MB_F2_OFFGLIDE
value.
Is this possible?