I would like to add a non-linear model with confidence band to my scatterplot. For the explanation, I am using vertical depth profile data of temperature, salinity etc. from 0 to 1000 m. After swapping the axes around, I unfortunately failed to add a regression model with confidence band. I would appreicate if any of you could help me getting started with this.
My data look like this:
CTD Area Station Cast Lat Long Month Day Hour Temp Sal DO Fluo Depth
898 9102 1 12 1 -44.59 174.2 10 24 20 10.7 34.6 282.9 1.7 1.0
899 9102 1 12 1 -44.59 174.2 10 24 20 10.7 34.6 282.4 1.5 2.0
900 9102 1 12 1 -44.59 174.2 10 24 20 10.7 34.6 282.7 1.5 3.0
901 9102 1 12 1 -44.59 174.2 10 24 20 10.7 34.6 282.5 1.6 4.0
902 9102 1 12 1 -44.59 174.2 10 24 20 10.7 34.6 282.3 1.8 5.0
903 9102 1 12 1 -44.59 174.2 10 24 20 10.7 34.6 282.4 1.9 6.0
904 9102 1 12 1 -44.59 174.2 10 24 20 10.7 34.6 282.8 1.8 7.0
905 9102 1 12 1 -44.59 174.2 10 24 20 10.7 34.6 282.7 1.7 7.9
906 9102 1 12 1 -44.59 174.2 10 24 20 10.7 34.6 282.2 1.7 8.9
907 9102 1 12 1 -44.59 174.2 10 24 20 10.7 34.6 282.2 2.1 9.9
908 9102 1 12 1 -44.59 174.2 10 24 20 10.7 34.6 282.1 1.9 10.9
909 9102 1 12 1 -44.59 174.2 10 24 20 10.7 34.6 282.2 1.7 11.9
910 9102 1 12 1 -44.59 174.2 10 24 20 10.7 34.6 282.4 2.3 12.9
911 9102 1 12 1 -44.59 174.2 10 24 20 10.7 34.6 282.8 1.7 13.9
912 9102 1 12 1 -44.59 174.2 10 24 20 10.7 34.6 282.9 1.4 14.9
913 9102 1 12 1 -44.59 174.2 10 24 20 10.7 34.6 283.0 1.5 15.9
914 9102 1 12 1 -44.59 174.2 10 24 20 10.7 34.6 282.9 1.4 16.9
915 9102 1 12 1 -44.59 174.2 10 24 20 10.7 34.6 282.4 1.6 17.9
916 9102 1 12 1 -44.59 174.2 10 24 20 10.7 34.6 281.5 1.6 18.9
917 9102 1 12 1 -44.59 174.2 10 24 20 10.7 34.6 280.9 1.5 19.9
918 9102 1 12 1 -44.59 174.2 10 24 20 10.7 34.6 281.9 1.9 20.9
919 9102 1 12 1 -44.59 174.2 10 24 20 10.7 34.6 284.8 1.4 21.9
920 9102 1 12 1 -44.59 174.2 10 24 20 10.7 34.6 286.4 1.5 22.8
921 9102 1 12 1 -44.59 174.2 10 24 20 10.7 34.6 286.5 1.8 23.8
922 9102 1 12 1 -44.59 174.2 10 24 20 10.7 34.6 285.7 1.8 24.8
In the given example the temperature in the uppermost 25 m isn't changing but believe me, it does below.
So far my code looks like this:
p1<-ggplot(A1,aes(x=Temp,y=Depth,group=Cast))+
geom_point()+xlim(c(6,12))+scale_y_reverse(lim=c(500,0))
p1