Skip to content

Commit

Permalink
additional parameters plotCorrHist2D
Browse files Browse the repository at this point in the history
  • Loading branch information
emolinab committed Feb 2, 2024
1 parent 89c4ac6 commit f581469
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .buildlibrary
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ValidationKey: '70762496'
ValidationKey: '70821675'
AutocreateReadme: yes
AcceptedWarnings:
- 'Warning: package ''.*'' was built under R version'
Expand Down
4 changes: 2 additions & 2 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ cff-version: 1.2.0
message: If you use this software, please cite it using the metadata from this file.
type: software
title: 'luplot: Landuse Plot Library'
version: 3.58.4
date-released: '2024-01-22'
version: 3.58.5
date-released: '2024-02-02'
abstract: Some useful functions to plot data such as a map plot function for MAgPIE
objects.
authors:
Expand Down
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Type: Package
Package: luplot
Title: Landuse Plot Library
Version: 3.58.4
Date: 2024-01-22
Version: 3.58.5
Date: 2024-02-02
Authors@R: c(
person("Benjamin Leon", "Bodirsky", , "[email protected]", role = c("aut", "cre")),
person("Jan Philipp", "Dietrich", , "[email protected]", role = "aut"),
Expand Down Expand Up @@ -45,4 +45,4 @@ Suggests:
covr
Encoding: UTF-8
LazyData: no
RoxygenNote: 7.3.0
RoxygenNote: 7.3.1
12 changes: 8 additions & 4 deletions R/plotCorrHist2D.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
#' @param TitleFontSize Font size of title of correlation plot
#' @param legendTitleFont Font size of the title of the legend
#' @param legendTextFont Font size of legend
#' @param table Conditional to include table with statistics in the output. TRUE (includes it), FALSE (it doesn't)
#' @param stat Conditional to include R2 and MAE on the fiure. TRUE (includes it), FALSE (it doesn't)
#' @author Edna Molina Bacca
#' @importFrom grDevices colorRampPalette
#' @importFrom ggplot2 ggplot aes_ xlim ylim scale_fill_gradientn coord_fixed geom_abline geom_vline geom_hline
Expand All @@ -40,7 +42,8 @@
#'
plotCorrHist2D <- function(x, y, title = NULL, xlab = "x", ylab = "y", bins = 40, limx=NULL, limy=NULL,
folder = NULL, file = "", breaks = waiver(),nrows=2, ncols=2, axisFont=13,
axisTitleFont=13,TitleFontSize=15,legendTitleFont=12,legendTextFont=10,statFont=4) {
axisTitleFont=13,TitleFontSize=15,legendTitleFont=12,legendTextFont=10,
statFont=4, table=FALSE, stat=TRUE) {


getNames(x) <- gsub(x = getNames(x), pattern = "\\.", replacement = "_")
Expand Down Expand Up @@ -114,9 +117,9 @@ plotCorrHist2D <- function(x, y, title = NULL, xlab = "x", ylab = "y", bins = 40
legend.title = element_text(size = legendTitleFont),
legend.background = element_blank())

plots[[tag]] <- plots[[tag]] + annotate("label", size = statFont, x = labelX, y = labelY,
plots[[tag]] <- if(stat) plots[[tag]] + annotate("label", size = statFont, x = labelX, y = labelY,
label = paste0("R2 = ", r2), hjust = 1)
plots[[tag]] <- plots[[tag]] + annotate("label", size = statFont, x = labelX, y = labelY2,
plots[[tag]] <- if(stat) plots[[tag]] + annotate("label", size = statFont, x = labelX, y = labelY2,
label = paste0("MAE = ", mae), hjust = 1)
plots[[tag]] <- if (!is.null(limx)) plots[[tag]] + scale_x_continuous(limits = limx) else plots[[tag]] + scale_x_continuous(limits = limx1)
plots[[tag]] <- if (!is.null(limy)) plots[[tag]] + scale_y_continuous(limits = limy) else plots[[tag]] + scale_y_continuous(limits = limy1)
Expand All @@ -132,5 +135,6 @@ plotCorrHist2D <- function(x, y, title = NULL, xlab = "x", ylab = "y", bins = 40
write.csv2(corr,paste0(folder, file, "_stats.csv"))
}

return(plots)
out <- if (table) list(plots,corr) else plots
return(out)
}
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Landuse Plot Library

R package **luplot**, version **3.58.4**
R package **luplot**, version **3.58.5**

[![CRAN status](https://www.r-pkg.org/badges/version/luplot)](https://cran.r-project.org/package=luplot) [![R build status](https://github.com/pik-piam/luplot/workflows/check/badge.svg)](https://github.com/pik-piam/luplot/actions) [![codecov](https://codecov.io/gh/pik-piam/luplot/branch/master/graph/badge.svg)](https://app.codecov.io/gh/pik-piam/luplot) [![r-universe](https://pik-piam.r-universe.dev/badges/luplot)](https://pik-piam.r-universe.dev/builds)

Expand Down Expand Up @@ -39,7 +39,7 @@ In case of questions / problems please contact Benjamin Bodirsky <bodirsky@pik-p

To cite package **luplot** in publications use:

Bodirsky B, Dietrich J, Krause M, Stevanovic M, Humpenoeder F, Weindl I, Baumstark L, Klein D, Rolinski S, Wang X (2024). _luplot: Landuse Plot Library_. R package version 3.58.4, <URL: https://github.com/pik-piam/luplot>.
Bodirsky B, Dietrich J, Krause M, Stevanovic M, Humpenoeder F, Weindl I, Baumstark L, Klein D, Rolinski S, Wang X (2024). _luplot: Landuse Plot Library_. R package version 3.58.5, <URL: https://github.com/pik-piam/luplot>.

A BibTeX entry for LaTeX users is

Expand All @@ -48,7 +48,7 @@ A BibTeX entry for LaTeX users is
title = {luplot: Landuse Plot Library},
author = {Benjamin Leon Bodirsky and Jan Philipp Dietrich and Michael Krause and Miodrag Stevanovic and Florian Humpenoeder and Isabelle Weindl and Lavinia Baumstark and David Klein and Susanne Rolinski and Xiaoxi Wang},
year = {2024},
note = {R package version 3.58.4},
note = {R package version 3.58.5},
url = {https://github.com/pik-piam/luplot},
}
```

0 comments on commit f581469

Please sign in to comment.