[R] Help reproducing a contour plot

Rui Barradas ruipbarradas at sapo.pt
Wed Sep 19 21:53:04 CEST 2012


Hello,

I remember this dataset from not a long time ago. Please use dput() to 
post your data and do not use formatting to post code.

As for the question, though your example is not reproducible (it doesn't 
run) see

http://gallery.r-enthusiasts.com/graph/contour_plot_%3Cbr%3EMaunga_Whau_Volcano,21

Hope this helps,

Rui Barradas
Em 19-09-2012 16:55, Tinus Sonnekus escreveu:
> Hi All,
>
> I am trying to reproduce this using R instead.
>
> [image: Full-size image (38 K)]
>
>
> I tried using the following code
>
> *SChla <- read.csv("SM_Chla_data.csv")*
>
> *Atlantis <- SChla[16:66,]*
> *head(Atlantis)*
> *
> *
>     Seamount Station   Depth   Pico   Nano  Micro Total_Ch    dbar  Latitude
> Longitud
> 16 Atlantis    1217 Surface 0.0639 0.1560 0.0398   0.2597   2.082 -32.71450
> 57.29733
> 17 Atlantis    1217 Shallow 0.0305 0.1250 0.0740   0.2295  24.524 -32.71450
> 57.29733
> 18 Atlantis    1217    Deep 0.1660 0.3560 0.0734   0.5954  49.573 -32.71450
> 57.29733
> 19 Atlantis    1217    Fmax 0.1740 0.5200 0.1830   0.8770  79.595 -32.71450
> 57.29733
> 20 Atlantis    1217   Below 0.0235 0.0486 0.0242   0.0963 199.067 -32.71450
> 57.29733
> 21 Atlantis    1225 Surface 0.0764 0.1490 0.0333   0.2587   0.409 -32.71133
> 57.27150
>
> *# Obtaining longitude and depth data*
> *Long <- SMfrac[,6]*
> *dbar <- -SMfrac[,5] #reverse depth*
> *
> *
> *#converting data to percentage of total chl a*
> *
> *
> *picoFrac <- Atlantis$Pico/Atlantis$Total_Ch*100*
> *nanoFrac <- Atlantis$Nano/Atlantis$Total_Ch*100*
> *microFrac <- Atlantis$Micro/Atlantis$Total_Ch*100*
> *
> *
> *
> *
> *library(akima)*
> *
> *
> *par(mfrow = c(3,1)) *
> *
> *
> *contour(interp(Long, dbar, picoFrac),nlevels = 6,*
> * xlab ="Longitude", main= "Pico", *
> *       ylab ="Depth", ylim = c(-200,0), method = "simple",*
> *       col = "light green")*
> *
> *
> *contour(interp(Long, dbar, nanoFrac), nlevels = 6,*
> * xlab ="Longitude", main= "Nano",*
> *       ylab ="Depth",ylim = c(-200,0), method = "simple",*
> *       col = "green")*
> *
> *
> *contour(interp(Long, dbar, microFrac),nlevels = 6,*
> * xlab ="Longitude", main= "Micro",*
> *       ylab ="Depth",ylim = c(-200,0),     *
> *       lylab ="Depth", method = "simple",*
> *       col = "dark green")*
>
> I can get the contours plotted. Not sure if this is 100 % correct but it
> looks as expected. Can you guys please help me to add/display my data
> points. I would also like to fill the contours in grayscale/colour (e.g.
> levels 0, 20, 40, 60, 80. 100 %) and add a legend to the graph. As of yet I
> haven't tried to figure out how to add the stations as a secondary axis to
> the plot.
>
>
> Thanks for the help and advice.
> Tinus
>




More information about the R-help mailing list