forked from mishahublog/BioArgo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlot_Bioargo.R
80 lines (76 loc) · 3.38 KB
/
Plot_Bioargo.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#===============================================================
#Plotting functions for BioArgo
#
#===================================================================
# plotting overview of graphs, with options to plot single graphs
#This function returns all the plots in a single functions
# Always be trimmed before plotting according to your needs
plot_BioArgo<- function(x,temperature=FALSE,salinity=FALSE,
oxygen=FALSE,chlorophyll=FALSE,...)
{
# make it true, when you want only temperature
if(temperature==TRUE){
plot(x[[6]],-x[[5]],xlab = "", ylab = names(x)[5],xaxt="n",yaxt="n",type = "l",col="red",...)
axis(3)
axis(2,at = seq(min(-x[5]),max(-x[5]),by = 100),labels = rev(round(seq(min(x[5]),max(x[5]),by = 100))))
mtext(names(x)[6],side = 3,line = 2)
mtext(names(x)[5],side = 2,line = 3)
}
# make it true, when you want only salinity
else
if(salinity==TRUE){
plot(x[[7]],-x[[5]],xlab = "", ylab = names(x)[5],xaxt="n",yaxt="n",type = "l",col="blue",...)
axis(3)
axis(2,at = seq(min(-x[5]),max(-x[5]),by = 100),labels = rev(round(seq(min(x[5]),max(x[5]),by = 100))))
mtext(names(x)[7],side = 3,line = 2)
mtext(names(x)[5],side = 2,line = 3)
}
# make it true, when you want only oxygen
else
if(oxygen==TRUE){
plot(x[[8]],-x[[5]],xlab = "", ylab = names(x)[5],xaxt="n",yaxt="n",type = "l",col="orange",...)
axis(3)
axis(2,at = seq(min(-x[5]),max(-x[5]),by = 100),labels = rev(round(seq(min(x[5]),max(x[5]),by = 100))))
mtext(names(x)[8],side = 3,line = 2)
mtext(names(x)[5],side = 2,line = 3)
}
# make it true, when you want only chlorophyll
else
if(chlorophyll==TRUE){
plot(x[[9]],-x[[5]],xlab = "", ylab = names(x)[4],xaxt="n",yaxt="n",type = "l",col="green",...)
axis(3)
axis(2,at = seq(min(-x[5]),max(-x[5]),by = 100),labels = rev(round(seq(min(x[5]),max(x[5]),by = 100))))
mtext(names(x)[9],side = 3,line = 2)
mtext(names(x)[5],side = 2,line = 3)
}
#if you don't have any option this wil plot the whole graph in a panel
else
{
#set parameters
par(mfrow=c(2,2))
par(mar=c(2,4,4,2))
#plot all the four plots
plot(x[[6]],-x[[5]],xlab = "", ylab = "",xaxt="n",yaxt="n",type = "l",col="red",...)
axis(3)
axis(2,at = seq(min(-x[5]),max(-x[5]),by = 100),labels = rev(round(seq(min(x[5]),max(x[5]),by = 100))))
mtext(names(x)[6],side = 3,line = 2)
mtext(names(x)[5],side = 2,line = 3)
plot(x[[7]],-x[[5]],xlab = "", ylab = "",xaxt="n",yaxt="n",type = "l",col="blue",...)
axis(3)
axis(2,at = seq(min(-x[5]),max(-x[5]),by = 100),labels = rev(round(seq(min(x[5]),max(x[5]),by = 100))))
mtext(names(x)[7],side = 3,line = 2)
mtext(names(x)[5],side = 2,line = 3)
plot(x[[8]],-x[[5]],xlab = "", ylab = "",xaxt="n",yaxt="n",type = "l",col="orange",...)
axis(3)
axis(2,at = seq(min(-x[5]),max(-x[5]),by = 100),labels = rev(round(seq(min(x[5]),max(x[5]),by = 100))))
mtext(names(x)[8],side = 3,line = 2)
mtext(names(x)[5],side = 2,line = 3)
plot(x[[9]],-x[[5]],xlab = "", ylab = "",xaxt="n",yaxt="n",type = "l",col="green",...)
axis(3)
axis(2,at = seq(min(-x[5]),max(-x[5]),by = 100),labels = rev(round(seq(min(x[5]),max(x[5]),by = 100))))
mtext(names(x)[9],side = 3,line = 2)
mtext(names(x)[5],side = 2,line = 3)
library(crayon)
cat(blue("follow pepprbook.com for do More in R "))
}
}