Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
biospheremetrics
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Fabian Stenzel
biospheremetrics
Commits
c93ead1e
Commit
c93ead1e
authored
1 year ago
by
Fabian Stenzel
Browse files
Options
Downloads
Patches
Plain Diff
mod plot_biocol
parent
02da8260
No related branches found
No related tags found
2 merge requests
!6
Merge reviewed package into main
,
!5
Merge review_paper version to master
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
R/plot_biocol.R
+27
-26
27 additions, 26 deletions
R/plot_biocol.R
with
27 additions
and
26 deletions
R/plot_biocol.R
+
27
−
26
View file @
c93ead1e
...
...
@@ -185,12 +185,11 @@ plot_biocol <- function(
#' Haberl et al. 2007
#'
#' @param data array containing BioCol percentage value for each gridcell
#' @param file character string for location/file to save plot to
#' @param plotyears range of years to plot over time
#' @param title character string title for plot
#' @param legendtitle character string legend title
#' @param file to write into, if not supplied (default is NULL) write to screen
#' @param title character string title for plot (default: "")
#' @param legendtitle character string legend title (default: "")
#' @param zero_threshold smallest value to be distinguished from 0 in legend,
#' both for negative and positive values (default: 0.1)
#' both for negative and positive values (default: 0.
00
1)
#' @param haberl_legend use color palette from Haberl et al.? (default: FALSE)
#' @param eps write eps file instead of PNG (boolean) - (default: FALSE)
#'
...
...
@@ -206,15 +205,30 @@ plot_biocol <- function(
#' @export
plot_biocol_map
<-
function
(
data
,
file
,
file
=
NULL
,
title
=
""
,
legendtitle
=
""
,
zero_threshold
=
0.001
,
eps
=
FALSE
,
haberl_legend
=
FALSE
)
{
path_write
<-
dirname
(
file
)
dir.create
(
file.path
(
path_write
),
showWarnings
=
FALSE
,
recursive
=
TRUE
)
haberl_legend
=
FALSE
,
eps
=
FALSE
)
{
if
(
!
is.null
(
file
))
{
path_write
<-
dirname
(
file
)
dir.create
(
file.path
(
path_write
),
showWarnings
=
FALSE
,
recursive
=
TRUE
)
if
(
eps
)
{
file
<-
strsplit
(
file
,
"."
,
fixed
=
TRUE
)[[
1
]]
file
<-
paste
(
c
(
file
[
1
:
(
length
(
file
)
-
1
)],
"eps"
),
collapse
=
"."
)
grDevices
::
ps.options
(
family
=
c
(
"Helvetica"
),
pointsize
=
18
)
grDevices
::
postscript
(
file
,
horizontal
=
FALSE
,
onefile
=
FALSE
,
width
=
22
,
height
=
8.5
,
paper
=
"special"
)
}
else
{
grDevices
::
png
(
file
,
width
=
7.25
,
height
=
3.5
,
units
=
"in"
,
res
=
300
,
pointsize
=
6
,
type
=
"cairo"
)
}
}
if
(
haberl_legend
)
{
brks
<-
c
(
-400
,
-200
,
-100
,
-50
,
-
zero_threshold
,
...
...
@@ -255,20 +269,7 @@ plot_biocol_map <- function(
data
[
data
<
brks
[
1
]]
<-
brks
[
1
]
data
[
data
>
brks
[
length
(
brks
)]]
<-
brks
[
length
(
brks
)]
if
(
eps
)
{
file
<-
strsplit
(
file
,
"."
,
fixed
=
TRUE
)[[
1
]]
file
<-
paste
(
c
(
file
[
1
:
(
length
(
file
)
-
1
)],
"eps"
),
collapse
=
"."
)
grDevices
::
ps.options
(
family
=
c
(
"Helvetica"
),
pointsize
=
18
)
grDevices
::
postscript
(
file
,
horizontal
=
FALSE
,
onefile
=
FALSE
,
width
=
22
,
height
=
8.5
,
paper
=
"special"
)
}
else
{
grDevices
::
png
(
file
,
width
=
7.25
,
height
=
3.5
,
units
=
"in"
,
res
=
300
,
pointsize
=
6
,
type
=
"cairo"
)
}
ra
<-
terra
::
rast
(
ncols
=
720
,
nrows
=
360
)
range
<-
range
(
data
)
ra
[
terra
::
cellFromXY
(
ra
,
cbind
(
lon
,
lat
))]
<-
data
...
...
@@ -284,7 +285,7 @@ plot_biocol_map <- function(
x
=
-180
,
y
=
50
,
fill
=
palette
,
border
=
palette
,
legend
=
classes
,
title
=
legendtitle
)
grDevices
::
dev.off
()
if
(
!
is.null
(
file
))
grDevices
::
dev.off
()
}
#' Plot absolute BioCol, overtime, maps, and npp into given folder
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment