Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Gbodjo Yawogan Jean Eudes
lab5
Commits
6933432e
Commit
6933432e
authored
Aug 11, 2019
by
eudesyawog
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adding ggplot script
parent
c67be180
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
104 additions
and
0 deletions
+104
-0
plots_stats.R
plots_stats.R
+104
-0
No files found.
plots_stats.R
0 → 100644
View file @
6933432e
library
(
readr
)
library
(
ggplot2
)
library
(
ggthemes
)
library
(
foreach
)
library
(
scales
)
library
(
dplyr
)
csv
=
c
(
"/home/je/Bureau/lab5/plots/niakhar_2017_radar_toggplot.csv"
,
"/home/je/Bureau/lab5/plots/niakhar_2017_radar_notree_toggplot.csv"
,
"/home/je/Bureau/lab5/plots/niakhar_2018_radar_toggplot.csv"
,
"/home/je/Bureau/lab5/plots/niakhar_2018_radar_notree_toggplot.csv"
,
"/home/je/Bureau/lab5/plots/nioro_2018_radar_toggplot.csv"
,
"/home/je/Bureau/lab5/plots/nioro_2018_radar_notree_toggplot.csv"
)
foreach
(
j
=
1
:
length
(
csv
))
%do%
{
df
<-
read.csv
(
csv
[
j
],
colClasses
=
c
(
"Date"
,
"character"
,
"character"
,
"Date"
,
"Date"
,
"double"
,
"double"
))
id
<-
unique
(
df
$
Plot
)
outName
<-
unlist
(
strsplit
(
csv
[
j
],
"/"
))[
7
]
outName
<-
gsub
(
".csv"
,
".pdf"
,
outName
)
pdf
(
paste
(
"/home/je/Bureau/lab5/plots/"
,
outName
,
sep
=
""
),
width
=
8.98
,
height
=
5.86
,
title
=
"Plot mean"
)
foreach
(
i
=
1
:
length
(
id
))
%do%
{
plot
<-
df
[
which
(
df
$
Plot
==
id
[
i
]),]
p
<-
ggplot
(
data
=
plot
,
aes
(
x
=
Date
,
y
=
Mean
))
+
geom_vline
(
xintercept
=
unique
(
plot
$
Sowing
),
colour
=
"grey50"
,
size
=
1
)
+
geom_vline
(
xintercept
=
unique
(
plot
$
Harvest
),
colour
=
"grey50"
,
size
=
1
)
+
geom_point
(
aes
(
color
=
Band
))
+
geom_line
(
aes
(
color
=
Band
))
+
geom_ribbon
(
aes
(
ymin
=
Mean
-
Std
,
ymax
=
Mean
+
Std
,
fill
=
Band
),
alpha
=
0.2
)
+
ggtitle
(
plot
$
Plot
)
+
ylab
(
"Value"
)
+
theme_bw
()
+
scale_x_date
(
name
=
"Time"
,
breaks
=
date_breaks
(
"months"
),
labels
=
date_format
(
"%b"
))
+
theme
(
axis.text.x
=
element_text
(
size
=
15
),
axis.text.y
=
element_text
(
size
=
15
),
axis.title
=
element_text
(
size
=
18
),
legend.title
=
element_text
(
size
=
18
),
legend.text
=
element_text
(
size
=
15
))
print
(
p
)
}
dev.off
()
}
csv
=
c
(
"/home/je/Bureau/lab5/plots/niakhar_2017_opt_toggplot.csv"
,
"/home/je/Bureau/lab5/plots/niakhar_2017_opt_notree_toggplot.csv"
,
"/home/je/Bureau/lab5/plots/niakhar_2017_opt_gapf_toggplot.csv"
,
"/home/je/Bureau/lab5/plots/niakhar_2017_opt_gapf_notree_toggplot.csv"
,
"/home/je/Bureau/lab5/plots/niakhar_2018_opt_toggplot.csv"
,
"/home/je/Bureau/lab5/plots/niakhar_2018_opt_notree_toggplot.csv"
,
"/home/je/Bureau/lab5/plots/niakhar_2018_opt_gapf_toggplot.csv"
,
"/home/je/Bureau/lab5/plots/niakhar_2018_opt_gapf_notree_toggplot.csv"
,
"/home/je/Bureau/lab5/plots/nioro_2018_opt_toggplot.csv"
,
"/home/je/Bureau/lab5/plots/nioro_2018_opt_notree_toggplot.csv"
,
"/home/je/Bureau/lab5/plots/nioro_2018_opt_gapf_toggplot.csv"
,
"/home/je/Bureau/lab5/plots/nioro_2018_opt_gapf_notree_toggplot.csv"
)
foreach
(
j
=
1
:
length
(
csv
))
%do%
{
df
<-
read.csv
(
csv
[
j
],
colClasses
=
c
(
"Date"
,
"character"
,
"character"
,
"Date"
,
"Date"
,
"double"
,
"double"
))
df
<-
filter
(
df
,
Band
%in%
c
(
"B2"
,
"B3"
,
"B4"
,
"B8"
,
"B5"
,
"B6"
,
"B7"
,
"B8A"
,
"B11"
,
"B12"
))
id
<-
unique
(
df
$
Plot
)
outName
<-
unlist
(
strsplit
(
csv
[
j
],
"/"
))[
7
]
outName
<-
gsub
(
".csv"
,
"_Bands.pdf"
,
outName
)
pdf
(
paste
(
"/home/je/Bureau/lab5/plots/"
,
outName
,
sep
=
""
),
width
=
8.98
,
height
=
5.86
,
title
=
"Plot mean"
)
foreach
(
i
=
1
:
length
(
id
))
%do%
{
plot
<-
df
[
which
(
df
$
Plot
==
id
[
i
]),]
p
<-
ggplot
(
data
=
plot
,
aes
(
x
=
Date
,
y
=
Mean
))
+
geom_vline
(
xintercept
=
unique
(
plot
$
Sowing
),
colour
=
"grey50"
,
size
=
1
)
+
geom_vline
(
xintercept
=
unique
(
plot
$
Harvest
),
colour
=
"grey50"
,
size
=
1
)
+
geom_point
(
aes
(
color
=
Band
))
+
geom_line
(
aes
(
color
=
Band
))
+
geom_ribbon
(
aes
(
ymin
=
Mean
-
Std
,
ymax
=
Mean
+
Std
,
fill
=
Band
),
alpha
=
0.2
)
+
ggtitle
(
plot
$
Plot
)
+
ylab
(
"Value"
)
+
theme_bw
()
+
scale_x_date
(
name
=
"Time"
,
breaks
=
date_breaks
(
"months"
),
labels
=
date_format
(
"%b"
))
+
theme
(
axis.text.x
=
element_text
(
size
=
15
),
axis.text.y
=
element_text
(
size
=
15
),
axis.title
=
element_text
(
size
=
18
),
legend.title
=
element_text
(
size
=
18
),
legend.text
=
element_text
(
size
=
15
))
print
(
p
)
}
dev.off
()
}
foreach
(
j
=
1
:
length
(
csv
))
%do%
{
df
<-
read.csv
(
csv
[
j
],
colClasses
=
c
(
"Date"
,
"character"
,
"character"
,
"Date"
,
"Date"
,
"double"
,
"double"
))
df
<-
filter
(
df
,
Band
%in%
c
(
"NDVI"
,
"NDWI"
,
"CIGreen"
,
"CIRedEdge"
,
"EVI"
,
"MSAVI2"
,
"GDVI"
))
id
<-
unique
(
df
$
Plot
)
outName
<-
unlist
(
strsplit
(
csv
[
j
],
"/"
))[
7
]
outName
<-
gsub
(
".csv"
,
"_Indices.pdf"
,
outName
)
pdf
(
paste
(
"/home/je/Bureau/lab5/plots/"
,
outName
,
sep
=
""
),
width
=
8.98
,
height
=
5.86
,
title
=
"Plot mean"
)
foreach
(
i
=
1
:
length
(
id
))
%do%
{
plot
<-
df
[
which
(
df
$
Plot
==
id
[
i
]),]
p
<-
ggplot
(
data
=
plot
,
aes
(
x
=
Date
,
y
=
Mean
))
+
geom_vline
(
xintercept
=
unique
(
plot
$
Sowing
),
colour
=
"grey50"
,
size
=
1
)
+
geom_vline
(
xintercept
=
unique
(
plot
$
Harvest
),
colour
=
"grey50"
,
size
=
1
)
+
geom_point
(
aes
(
color
=
Band
))
+
geom_line
(
aes
(
color
=
Band
))
+
geom_ribbon
(
aes
(
ymin
=
Mean
-
Std
,
ymax
=
Mean
+
Std
,
fill
=
Band
),
alpha
=
0.2
)
+
ggtitle
(
plot
$
Plot
)
+
ylab
(
"Value"
)
+
theme_bw
()
+
scale_x_date
(
name
=
"Time"
,
breaks
=
date_breaks
(
"months"
),
labels
=
date_format
(
"%b"
))
+
theme
(
axis.text.x
=
element_text
(
size
=
15
),
axis.text.y
=
element_text
(
size
=
15
),
axis.title
=
element_text
(
size
=
18
),
legend.title
=
element_text
(
size
=
18
),
legend.text
=
element_text
(
size
=
15
))
print
(
p
)
}
dev.off
()
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment