Skip to content

Commit 07e69f2

Browse files
committed
Changing color schemes of figures
1 parent f3d115b commit 07e69f2

File tree

10 files changed

+272
-134
lines changed

10 files changed

+272
-134
lines changed

R/06_prep_pop_size_data.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ high.pop.sizes <- rowsum(high.pop.sizes, spp_names)
107107

108108
## OBTAINING POPULATION SIZES FOR MISSING YEARS ##
109109
## Getting pop. sizes for all possible generation lengths
110-
gen.lengths <- c(10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 90, 100)
110+
gen.lengths <- c(7, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 90, 100)
111111
pos.gen.length <- sort(unique(gen.lengths * rep(c(1:3), each=length(gen.lengths))), decreasing = TRUE)
112112
miss.years <- 2018 - pos.gen.length
113113
miss.years1 <- miss.years[miss.years < 1992]

R/11_criterionC.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ for(x in 1:length(res.means)) {
2828
}
2929

3030
#### LOADING THREAT HABITAT AND ECOLOGY DATA ####
31-
## Includes species info on Generation Length and Proportion of matrue individuals
31+
## Includes species info on Generation Length and Proportion of mature individuals
3232
hab <- readRDS("data/threat_habitats.rds")
3333

3434
PopData <- merge(decline.models, hab, by.x= "row.names", by.y = "Name_submitted", all.x = TRUE)

R/12_area_of_habitat.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ hab.class <- toto$NB_LAB[grepl("ForestCover", toto$LegendTreeCoSimp)]
3737

3838
## Loading aggregated rasters and extracting the habitat loss/quality
3939
ano1 = 2000
40-
hab.map <- raster::stack(paste0("data/ESA_Land_Cover_map_",ano1,"_2015_AF_1km.tif"))
40+
hab.map <- raster::stack(paste0("data/ESA_Land_Cover_map_", ano1, "_2015_AF_1km.tif"))
4141
names(hab.map) <- paste("ESA",c(ano1,2015), sep=".")
4242
anos <- 2015 - ano1
4343

R/14_criterionA.R

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -286,9 +286,12 @@ colnames(mat) <- gsub(" ", "", colnames(mat))
286286
rownames(mat) <- gsub(" ", "", rownames(mat))
287287

288288
#Defining the colors of tracks and links
289-
grid.col = c(CR_25 = "red", EN_25 = "darkorange", VU_25 = "gold", LCorNT_25 = "khaki",
290-
CR_opt = "red", EN_opt = "darkorange", VU_opt = "gold", LCorNT_opt = "khaki")
291-
col_mat = rep(rev(c("red","darkorange","gold","khaki")), each=4)
289+
# grid.col = c(CR_25 = "red", EN_25 = "darkorange", VU_25 = "gold", LCorNT_25 = "khaki",
290+
# CR_opt = "red", EN_opt = "darkorange", VU_opt = "gold", LCorNT_opt = "khaki")
291+
# col_mat = rep(rev(c("red","darkorange","gold","khaki")), each=4)
292+
grid.col = c(CR_25 = "#CD0000", EN_25 = "#E69F00", VU_25 = "#FFFF00", LCorNT_25 = "khaki",
293+
CR_opt = "#CD0000", EN_opt = "#E69F00", VU_opt = "#FFFF00", LCorNT_opt = "khaki")
294+
col_mat = rep(rev(c("#CD0000","#E69F00","#FFFF00","khaki")), each=4)
292295
col_mat[mat >= 15] = adjustcolor(col_mat[mat >= 15], alpha.f = 0.5)
293296
col_mat[mat < 15] = adjustcolor(col_mat[mat < 15], alpha.f = 0.9)
294297
#col_mat[mat < 5] = "#00000000"
@@ -348,9 +351,12 @@ colnames(mat) <- gsub(" ", "", colnames(mat))
348351
rownames(mat) <- gsub(" ", "", rownames(mat))
349352

350353
#Defining the colors of tracks and links
351-
grid.col = c(CR_20= "red", EN_20 = "darkorange", VU_20 = "gold", LCorNT_20 = "khaki",
352-
CR_opt = "red", EN_opt = "darkorange", VU_opt = "gold", LCorNT_opt = "khaki")
353-
col_mat = rep(rev(c("red","darkorange","gold","khaki")), each=4)
354+
# grid.col = c(CR_20= "red", EN_20 = "darkorange", VU_20 = "gold", LCorNT_20 = "khaki",
355+
# CR_opt = "red", EN_opt = "darkorange", VU_opt = "gold", LCorNT_opt = "khaki")
356+
# col_mat = rep(rev(c("red","darkorange","gold","khaki")), each=4)
357+
grid.col = c(CR_20= "#CD0000", EN_20 = "#E69F00", VU_20 = "#FFFF00", LCorNT_20 = "khaki",
358+
CR_opt = "#CD0000", EN_opt = "#E69F00", VU_opt = "#FFFF00", LCorNT_opt = "khaki")
359+
col_mat = rep(rev(c("#CD0000","#E69F00","#FFFF00","khaki")), each=4)
354360
col_mat[mat >= 15] = adjustcolor(col_mat[mat >= 15], alpha.f = 0.5)
355361
col_mat[mat < 15] = adjustcolor(col_mat[mat < 15], alpha.f = 0.9)
356362
#col_mat[mat < 5] = "#00000000"
@@ -447,7 +453,9 @@ colnames(pct) <- gl.vals
447453
pct <- round(100 * pct/dim(all.GL)[1], 1)
448454

449455
par(mar=c(3,3.5,0.75, 0.25), mgp=c(1.9,0.25,0),tcl=-0.2,las=1)
450-
barplot(pct, horiz = FALSE, col = c("red","darkorange","gold","khaki"),
456+
barplot(pct, horiz = FALSE,
457+
# col = c("red","darkorange","gold","khaki"),
458+
col = c("#CD0000","#E69F00","#FFFF00","khaki"),
451459
legend.text = c("CR", "EN", "VU", "LC or NT"),
452460
xlab = "Generation length (years)",
453461
args.legend = list(ncol=4, x.intersp = 1, y.intersp = 1, yjust = -1,

R/23_figures.R

Lines changed: 152 additions & 49 deletions
Large diffs are not rendered by default.

R/99_functions.R

Lines changed: 46 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4153,8 +4153,10 @@ makeSubColor=function(main,no=3){
41534153
#'Draw a PieDonut plot
41544154
my.PieDonut=function(data,mapping,
41554155
start=getOption("PieDonut.start",0),
4156-
addPieLabel=TRUE,addDonutLabel=TRUE,
4157-
showRatioDonut=TRUE,showRatioPie=TRUE,
4156+
addPieLabel=TRUE,
4157+
addDonutLabel=TRUE,
4158+
showRatioDonut=TRUE,
4159+
showRatioPie=TRUE,
41584160
ratioByGroup=TRUE,
41594161
showRatioThreshold=getOption("PieDonut.showRatioThreshold",0.02),
41604162
labelposition=getOption("PieDonut.labelposition",2),
@@ -4175,18 +4177,25 @@ my.PieDonut=function(data,mapping,
41754177
pieLabelSize=4,
41764178
donutLabelSize=3,
41774179
titlesize=5,
4178-
explodePie=TRUE,explodeDonut=FALSE,
4179-
use.label=TRUE,use.labels=TRUE,
4180+
explodePie=TRUE,
4181+
explodeDonut=FALSE,
4182+
use.label=TRUE,
4183+
use.labels=TRUE,
41804184
family=getOption("PieDonut.family",""),
41814185
labels = NULL,
41824186
main.colors = NULL,
4187+
sub.colors = NULL,
41834188
correct.legend.x = NULL,
41844189
correct.legend.y = NULL,
41854190
tidy.legend.donut = NULL,
41864191
tidy.legend.pie = NULL,
41874192
plot.piedonut = TRUE,
41884193
ratioAccuracy = c("pie" = 0.1, "donut" = 0.1),
4189-
return = "both"){
4194+
return = "both",
4195+
legend.pie = FALSE,
4196+
legend.donut = FALSE,
4197+
explode.cor.pie = 1,
4198+
explode.cor.donut = 1){
41904199

41914200
# data = pie.df
41924201
# mapping = aes(category, main.criteria)
@@ -4199,8 +4208,8 @@ my.PieDonut=function(data,mapping,
41994208
# family = ""
42004209
# main.colors = cores[-1]
42014210

4202-
(cols=colnames(data))
4203-
if(use.labels) data=moonBook::addLabelDf(data,mapping)
4211+
(cols = colnames(data))
4212+
if (use.labels) data=moonBook::addLabelDf(data,mapping)
42044213

42054214
count<-NULL
42064215

@@ -4242,8 +4251,8 @@ my.PieDonut=function(data,mapping,
42424251
df$focus=0
42434252
if(explodePie) df$focus[explode]=explodePos
42444253
df$mid=(df$start1+df$end1)/2
4245-
df$x=ifelse(df$focus==0,0,df$focus*sin(df$mid))
4246-
df$y=ifelse(df$focus==0,0,df$focus*cos(df$mid))
4254+
df$x=ifelse(df$focus==0,0,df$focus*sin(df$mid) * explode.cor.pie)
4255+
df$y=ifelse(df$focus==0,0,df$focus*cos(df$mid) * explode.cor.pie)
42474256
df$label=df[[pies]]
42484257
df$ratio=df$Freq/sum(df$Freq)
42494258

@@ -4256,8 +4265,7 @@ my.PieDonut=function(data,mapping,
42564265
# as.character(df$label))
42574266
df$label = paste0(df$label, " (", scales::percent(df$ratio, accuracy = ratioAccuracy["pie"]), ")")
42584267
df$label[tidy.legend.pie] = gsub(" \\(", "\n(",df$label[tidy.legend.pie])
4259-
4260-
4268+
42614269
}
42624270

42634271
if(is.null(correct.legend.x)) {
@@ -4292,7 +4300,6 @@ my.PieDonut=function(data,mapping,
42924300
subColor = makeSubColor(mainCol, no = length(unique(data[[donuts]])))
42934301
subColor
42944302

4295-
42964303
data
42974304
if(!is.null(count)){
42984305

@@ -4380,8 +4387,8 @@ my.PieDonut=function(data,mapping,
43804387
xpos=df$focus[explode[i]]*sin(df$mid[explode[i]])
43814388
ypos=df$focus[explode[i]]*cos(df$mid[explode[i]])
43824389

4383-
df3$x[df3$pie==explode[i]]=xpos
4384-
df3$y[df3$pie==explode[i]]=ypos
4390+
df3$x[df3$pie==explode[i]] = xpos * explode.cor.donut
4391+
df3$y[df3$pie==explode[i]] = ypos * explode.cor.donut
43854392
}
43864393
}
43874394
df3$no=1:nrow(df3)
@@ -4442,6 +4449,22 @@ my.PieDonut=function(data,mapping,
44424449
}
44434450
df3
44444451

4452+
if (!is.null(sub.colors)) {
4453+
no.sub <- length(sub.colors)
4454+
no <- length(unique(data[[donuts]]))
4455+
4456+
if (no.sub == length(subColor)) subColor <- sub.colors
4457+
4458+
if (no.sub != no)
4459+
stop(cat("Length of subcolors is different than the number of", donuts))
4460+
4461+
if (no.sub == no) {
4462+
cores <- sub.colors
4463+
names(cores) <- sort(unique(data[[donuts]]))
4464+
subColor <- unname(cores[match(df3[[donuts]], names(cores))])
4465+
}
4466+
}
4467+
44454468
del=which(df3$Freq==0)
44464469
del
44474470
if(length(del)>0) subColor<-subColor[-del]
@@ -4462,15 +4485,16 @@ my.PieDonut=function(data,mapping,
44624485
fill = pies),alpha=pieAlpha,color=color, data = df) +
44634486
transparent()+
44644487
scale_fill_manual(values=mainCol)+
4465-
xlim(r3*c(-1.2,1.2)) + ylim(r3*c(-1,1)) + guides(fill=FALSE) +
4488+
xlim(r3*c(-1.2,1.2)) + ylim(r3*c(-1,1)) +
4489+
guides(fill = legend.pie) +
44664490
theme_void()
44674491

44684492
if ((labelposition == 1) & (is.null(donuts))) {
44694493
p1 <- p1 + geom_segment(aes_string(x = "segx", y = "segy",
44704494
xend="segxend",yend="segyend"),data=df)+
44714495
geom_text(aes_string(x="segxend",y="segyend",label="label",hjust="hjust",vjust="vjust"),size=pieLabelSize,data=df,family=family)
44724496

4473-
} else
4497+
} else {
44744498
if ((labelposition == 2) & (is.null(donuts))) {
44754499
p1<-p1+ geom_segment(aes_string(x="segx",y="segy",
44764500
xend="segxend",yend="segyend"),data=df[df$ratio<labelpositionThreshold,])+
@@ -4486,6 +4510,7 @@ my.PieDonut=function(data,mapping,
44864510
family = family
44874511
)
44884512
}
4513+
}
44894514

44904515
if(showPieName) p1<-p1+annotate("text",x=0,y=0,label=pies,size=titlesize,family=family)
44914516

@@ -4508,8 +4533,9 @@ my.PieDonut=function(data,mapping,
45084533
}
45094534

45104535
p3 <- p3 + transparent()+
4511-
scale_fill_manual(values=subColor)+
4512-
xlim(r3*c(-1,1))+ylim(r3*c(-1,1))+guides(fill=FALSE)+
4536+
scale_fill_manual(values=subColor) +
4537+
xlim(r3*c(-1,1))+ylim(r3*c(-1,1)) +
4538+
guides(fill = legend.donut) +
45134539
theme_void()
45144540

45154541
p3
@@ -4519,7 +4545,7 @@ my.PieDonut=function(data,mapping,
45194545
xend="segxend",yend="segyend"),data=df3)+
45204546
geom_text(aes_string(x="segxend",y="segyend",
45214547
label="label",hjust="hjust",vjust="vjust"),size=donutLabelSize,data=df3,family=family)
4522-
} else
4548+
} else {
45234549
if(labelposition==0){
45244550
p3<-p3+geom_text(aes_string(x="labelx",y="labely",
45254551
label="label"),size=donutLabelSize,data=df3,family=family)
@@ -4532,6 +4558,7 @@ my.PieDonut=function(data,mapping,
45324558
label="label"),size=donutLabelSize,data=df3[df3$ratio1>=labelpositionThreshold,],family=family)
45334559

45344560
}
4561+
}
45354562

45364563
if(!is.null(title))
45374564
p3<-p3+annotate("text",x=0,y=r3,label=title,size=titlesize,family=family)

README.Rmd

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ are:
5353

5454
1. **Definitions**: the basic definitions that will determine which species
5555
will be included in the assessments;
56-
2. **Species information**: the essential information that must be
56+
2. **Species information**: the information that must be
5757
compiled, estimated or imputed to obtain the population metrics;
5858
3. **Population metrics**: the estimation of the population metrics defined by
5959
the IUCN as indicators of the threat of a species or taxon;
@@ -71,22 +71,22 @@ and the export of the information necessary for submission to the IUCN Red List.
7171

7272
Note that the Pre-Assessment stage involves the compilation of key information
7373
from the study region and the group of organism included in the assessment.
74-
Although it represents the first steps of the workflow, the codes in this
74+
Although it represents the first step of the workflow, the code in this
7575
repository assume that this key information was already compiled, estimated, or
7676
imputed and that it is available in the `data` folder.
7777

78-
Note as well that our Post-assessment stage does not include the submission of
78+
Note as well that the Post-assessment stage does not include the submission of
7979
the assessments to the IUCN Red List and their review by the IUCN Red List
8080
units. This is beyond the scope of the workflow which is producing the
8181
conservation assessments and the associated files to facilitate the process of submission by the Red List Authority.
8282

8383
<br />
8484

8585

86-
##### Details on step 1
86+
##### Details on step 1 - Definitions
8787

88-
Step 1 will define which species will have global (for all populations of the
89-
species) or regional assessments (for populations of the species). For instance,
88+
Step 1 will define which assessment will be global (for all populations of the
89+
species) or regional (for some populations of the species). For instance,
9090
THREAT project has a regional scope (i.e. Atlantic Forest), so for species that
9191
are non-endemic and endemic to the Atlantic Forest the assessments are regional
9292
and global, respectively. This is why it is important to know beforehand the
@@ -104,7 +104,7 @@ process of reviewing the assessments before submission.
104104

105105
<br />
106106

107-
##### Details on step 2
107+
##### Details on step 2 - Species information
108108

109109
Species occurrence records are the input data used to obtain the species'
110110
geographic range and other spatial population metrics that are required to
@@ -128,7 +128,7 @@ specimen duplicates across biological collections.
128128

129129
<br />
130130

131-
##### Details on step 3
131+
##### Details on step 3 - Population metrics
132132

133133
Different population metrics are necessary for applying the IUCN criteria A, B,
134134
C and D (criterion E is currently not considered in this workflow). A new
@@ -141,8 +141,8 @@ a specific point in time (`ConR::pop.decline.fit()`), based on linear,
141141
exponential, quadratic, logistic and other trends of population decline
142142
through time. This is important because the time interval of population decline
143143
needed for the assessments of criterion A or C (10 years or one-, two- or
144-
three-generation lengths - see IUCN 2019) often do not correspond exactly to the
145-
observed population sizes for most species.
144+
three-generation lengths - see IUCN 2019) often does not correspond exactly to
145+
the observed population sizes for most species.
146146

147147
For criterion B, the `ConR` package provides functions for calculating the
148148
Extent of Occurrence (EOO - `ConR::EOO.computing()`), Area of Occupancy (AOO -
@@ -158,7 +158,7 @@ conditions necessary for assessing criterion B.
158158

159159
<br />
160160

161-
##### Details on step 4
161+
##### Details on step 4 - IUCN Red List Criteria assessment
162162

163163
This step corresponds to the assignment of one of the IUCN Red List Categories
164164
(i.e. EX, EW, CR, EN, VU, NT, LC, DD) by comparing the population metrics
@@ -170,9 +170,9 @@ of the `ConR` R package (Dauby et al. 2017, Dauby & Lima 2022 - see functions
170170
`ConR::criterion_D()`). A specific function was also developed to tell apart NT
171171
from LC categories (see function `ConR::near.threatened()`).
172172

173-
In the case of multiple IUCN criteria, there is also the need to generate a
174-
consensus IUCN Red List Category among the results of each IUCN Criteria (see
175-
function `ConR:::cat_mult_criteria()`).
173+
In the case of multiple IUCN Red List Criteria, there is also the need to
174+
generate a consensus IUCN Red List Category among the results of each IUCN
175+
Criteria (see function `ConR:::cat_mult_criteria()`).
176176

177177
This step of the workflow also includes the assignment of tags, such as the
178178
'Possibly Extinct' tag for Critically Endangered species or tags for species
@@ -193,7 +193,7 @@ include uncertainties in the assessments.
193193

194194
<br />
195195

196-
##### Details on step 5
196+
##### Details on step 5 - Summary and export
197197

198198
Many different summaries and analyses can be done to present the results of the
199199
assessments. Besides a general description of the results (e.g. proportion of
@@ -256,11 +256,11 @@ species defined based on their potential maximum height as an adult and on their
256256
ecological groups. The choice of which values were assigned to each group was
257257
based on the empirical evidence currently available in the literature.
258258

259-
Still related to criteria A and C, it is expected that harvest trends (e.g.
260-
timber species) and changes in habitat quality will have an impact on the change
261-
in population sizes. For long-lived organisms, this information will probably be
262-
missing for most species. But it is advised to take them into account for
263-
calibrating the final results of the assessments.
259+
Still related to the IUCN criteria A and C, it is expected that harvest trends
260+
(e.g. timber species) and changes in habitat quality will have an impact on the
261+
change in population sizes. For long-lived organisms, this information will
262+
probably be missing for most species. But it is advised to take them into
263+
account for calibrating the final results of the assessments.
264264

265265
For the assessment of criteria B, the Average Dispersal Distance (DD) is
266266
mandatory information for estimating the number of subpopulations and their
@@ -367,11 +367,11 @@ Renato A. F. de Lima & Gilles Dauby
367367

368368
Please cite this repository as:
369369

370-
> **{{ Renato A. F. de Lima, Gilles Dauby, André L. de Gasper, Eduardo P.
370+
> **Renato A. F. de Lima, Gilles Dauby, André L. de Gasper, Eduardo P.
371371
Fernandez, Alexander C. Vibrans, Alexandre A. de Oliveira, Paulo I. Prado,
372372
Vinícius C. Souza, Marinez F. de Siqueira & Hans ter Steege. (2023). The
373373
Atlantic Forest trees: a flora on the verge of extinction. Manuscript under
374-
review }}**
374+
review**
375375

376376
### Funding
377377

0 commit comments

Comments
 (0)