I have created the following plot:
The data:
lat<-c(37.30,37.30,37.30,37.30,69.25,69.25,37.30,0.00,0.00,37.30,37.30,37.30,37.30,-75.00,-75.00,70.00,25.30,25.30,37.30,45.00,46.75,-49.00,-49.00,-49.00,58.50,-37.00,37.30,37.30,37.30,37.30,69.25,69.25,37.30,0.00,0.00,37.30,37.30,37.30,37.30,-75.00,-75.00,70.00,25.30,25.30,37.30,-49.00,-49.00,-49.00,16.10,-9.12,50.00,30.00)
prop<-c(64, 62, 38, 37, 50, 30, 27, 10, 25, 39, 25, 6, 5, 25, 47, 24, 20, 2, 62, 40, 48, 60, 20, 40, 66, 57, 14, 25, 11, 0, 3, 5, 0, 0, 0, 14, 10, 11, 9, 1, 1, 34, 20, 90, 0, 0, 0, 0, 4, 5, 85, 6)
group<-c("gnc","gnc","gnc","gnc","gnc","gnc","gnc","gnc","gnc","gnc","gnc","gnc","gnc","gnc","gnc","gnc","gnc","gnc","gnc","gnc","gnc","gnc","gnc","gnc","gnc","gnc","mr","mr","mr","mr","mr","mr","mr","mr","mr","mr","mr","mr","mr","mr","mr","mr","mr","mr","mr","mr","mr","mr","mr","mr","mr","mr")
mydata<-data.frame(lat,prop,group)
The graph:
library(ggplot2)
library(scales)
ggplot(data=mydata,aes(x=lat,y=prop,colour=group))+
geom_point(size=2.3) +
stat_smooth(span=0.75,n=26,method="loess",aes(fill=group)) +
theme_bw()+
theme(
panel.grid.minor=element_blank(),
panel.grid.major=element_blank(),
legend.position=c(0.15,0.85),
legend.title=element_blank(),
axis.text=element_text(size=17),
axis.title=element_text(size=19),
legend.text=element_text(size=17)
)+
scale_y_continuous(limit=c(0,NA),oob=squish)+
scale_x_continuous(limit=c(-70,70),oob=squish,breaks=c(-60,-30,0,30,60))
However, this is not the final plot that I want. I would like to keep the output from the loess regressions as shown in the plot above but present the graph with prop in the x-axis and lat in the y-axis. I know that for statistics the correct is to keep the dependent variable (i.e., prop) in the y-axis, but my independent variable (i.e., lat) represents Latitude, and it would be interesting to show latitude in the vertical position (y-axis).
If I simply change the following line of code stating that x=prop and y=lat my loess regressions will respect this statement and will not produce the desirable fit (i.e., prop as a function of lat).
ggplot(data=mydata,aes(x=prop,y=lat,colour=group))+
Any ideas on how to reproduce exactly the plot above (i.e., maintaining the loess regressions as they are) but with prop in x-axis and lat in y-axis?