Add SE bars to mean points in a scatterplot

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Add SE bars to mean points in a scatterplot

Ksway
This post was updated on .
Hi,

I am trying to create dual isotope plot for d15N and d13C isotope values for different fish species. This is what it looks like in another publication:


For my data, I have the mean d15N and d13C values for each species. I have managed to plot it on a scatterplot using this code (I know there is surely a simpler way of doing this, but this works ok):

dualALLE<-AVGSIATOT2013
par(mar=c(5.1, 4.1, 4.1, 10), xpd=TRUE)
plot(dualALLE$AVG13C,dualALLE$AVG15N, pch=unclass(dualALLE$Code), xlab="δ13C ", ylab="δ15N ")

points(dualALLE$AVG13C[dualALLE$Code=='1'], dualALLE$AVG15N[dualALLE$Code=='1'], pch=1)
points(dualALLE$AVG13C[dualALLE$Code=='2'], dualALLE$AVG15N[dualALLE$Code=='2'], pch=2)
points(dualALLE$AVG13C[dualALLE$Code=='3'], dualALLE$AVG15N[dualALLE$Code=='3'], pch=3)
points(dualALLE$AVG13C[dualALLE$Code=='4'], dualALLE$AVG15N[dualALLE$Code=='4'], pch=4)
points(dualALLE$AVG13C[dualALLE$Code=='5'], dualALLE$AVG15N[dualALLE$Code=='5'], pch=5)
points(dualALLE$AVG13C[dualALLE$Code=='6'], dualALLE$AVG15N[dualALLE$Code=='6'], pch=6)
points(dualALLE$AVG13C[dualALLE$Code=='7'], dualALLE$AVG15N[dualALLE$Code=='7'], pch=7)
points(dualALLE$AVG13C[dualALLE$Code=='8'], dualALLE$AVG15N[dualALLE$Code=='8'], pch=8)
points(dualALLE$AVG13C[dualALLE$Code=='9'], dualALLE$AVG15N[dualALLE$Code=='9'], pch=9)
points(dualALLE$AVG13C[dualALLE$Code=='10'], dualALLE$AVG15N[dualALLE$Code=='10'], pch=10)
points(dualALLE$AVG13C[dualALLE$Code=='11'], dualALLE$AVG15N[dualALLE$Code=='11'], pch=11)
points(dualALLE$AVG13C[dualALLE$Code=='12'], dualALLE$AVG15N[dualALLE$Code=='12'], pch=12)
points(dualALLE$AVG13C[dualALLE$Code=='13'], dualALLE$AVG15N[dualALLE$Code=='13'], pch=13)
points(dualALLE$AVG13C[dualALLE$Code=='14'], dualALLE$AVG15N[dualALLE$Code=='14'], pch=14)
points(dualALLE$AVG13C[dualALLE$Code=='15'], dualALLE$AVG15N[dualALLE$Code=='15'], pch=15)
points(dualALLE$AVG13C[dualALLE$Code=='16'], dualALLE$AVG15N[dualALLE$Code=='16'], pch=16)
points(dualALLE$AVG13C[dualALLE$Code=='17'], dualALLE$AVG15N[dualALLE$Code=='17'], pch=17)
points(dualALLE$AVG13C[dualALLE$Code=='18'], dualALLE$AVG15N[dualALLE$Code=='18'], pch=18)
points(dualALLE$AVG13C[dualALLE$Code=='19'], dualALLE$AVG15N[dualALLE$Code=='29'], pch=19)
points(dualALLE$AVG13C[dualALLE$Code=='20'], dualALLE$AVG15N[dualALLE$Code=='20'], pch=20)
points(dualALLE$AVG13C[dualALLE$Code=='21'], dualALLE$AVG15N[dualALLE$Code=='21'], pch=21)
points(dualALLE$AVG13C[dualALLE$Code=='22'], dualALLE$AVG15N[dualALLE$Code=='22'], pch=22)


legend("topright", inset=c(-0.5, -0.1), legend=c("MSK", "TBSK", "LI", "GBFL", "EF", "AS", "SPD", "TAS", "HOU", "CR", "SH"), pch=c(1:11), title="Species")

legend("topright", inset=c(-0.9, -0.1), legend=c("GA", "SG", "PHY", "FIL", "BM", "POD", "HH", "JT", "PIL", "SF", "MU"), pch=c(12:22), title="Species")

This gives me:


However, I need to insert standard error bars here for each point.

Any idea how I can add SE bars to each point for my scatterplot by adding to this code?

Many Thanks in advance!