Skip to content

Commit

Permalink
Merge pull request #12 from pascal-sauer/master
Browse files Browse the repository at this point in the history
major cleanup
  • Loading branch information
pascal-sauer authored May 29, 2024
2 parents e018353 + c2ed894 commit 40d0c44
Show file tree
Hide file tree
Showing 66 changed files with 217 additions and 3,327 deletions.
2 changes: 1 addition & 1 deletion .buildlibrary
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ValidationKey: '72254000'
ValidationKey: '7948400'
AutocreateReadme: yes
AcceptedWarnings:
- 'Warning: package ''.*'' was built under R version'
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@
.Rhistory
.RData
.Ruserdata
/man/
7 changes: 5 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.64.0
date-released: '2024-05-07'
version: 4.0.0
date-released: '2024-05-28'
abstract: Some useful functions to plot data such as a map plot function for MAgPIE
objects.
authors:
Expand Down Expand Up @@ -40,6 +40,9 @@ authors:
- family-names: Chen
given-names: David
email: [email protected]
- family-names: Sauer
given-names: Pascal
email: [email protected]
license: LGPL-3.0
repository-code: https://github.com/pik-piam/luplot

26 changes: 11 additions & 15 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.64.0
Date: 2024-05-07
Version: 4.0.0
Date: 2024-05-28
Authors@R: c(
person("Benjamin Leon", "Bodirsky", , "[email protected]", role = c("aut", "cre")),
person("Jan Philipp", "Dietrich", , "[email protected]", role = "aut"),
Expand All @@ -14,35 +14,31 @@ Authors@R: c(
person("David", "Klein", , "[email protected]", role = "aut"),
person("Susanne", "Rolinski", , "[email protected]", role = "aut"),
person("Xiaoxi", "Wang", , "[email protected]", role = "aut"),
person("David", "Chen", , "[email protected]", role = "aut")
person("David", "Chen", , "[email protected]", role = "aut"),
person("Pascal", "Sauer", , "[email protected]", role = "aut")
)
Maintainer: Benjamin Bodirsky <[email protected]>
Description: Some useful functions to plot data such as a map plot
function for MAgPIE objects.
License: LGPL-3 | file LICENSE
URL: https://github.com/pik-piam/luplot
Depends:
R (>= 2.15.1),
magclass
magclass,
R (>= 2.15.1)
Imports:
RColorBrewer,
data.table,
dplyr,
fields,
ggplot2,
grDevices,
graphics,
luscale,
grDevices,
gridExtra,
lusweave,
magpiesets,
mip,
mstools (>= 0.6.0),
quitte,
RColorBrewer,
reshape2,
rworldmap (>= 1.3.8),
sp,
xml2,
gridExtra,
mstools (>= 0.6.0)
utils
Suggests:
covr
Encoding: UTF-8
Expand Down
63 changes: 1 addition & 62 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,49 +1,27 @@
# Generated by roxygen2: do not edit by hand

export(aggregate_for_plot)
export(alloc_plot)
export(aggregateForPlot)
export(as.ggplot)
export(comparisonplot)
export(deco_plot)
export(get_layout_parameters)
export(gg.reg.x.crop)
export(gginput)
export(histoplot)
export(histoplot2)
export(magpie2ggplot)
export(magpie2ggplot2)
export(magpie2map)
export(map2image)
export(mipAreaOverlapFirstNameFacetSecondNameStacked)
export(nice_colors)
export(nitrogen_sankey)
export(performancePlot)
export(plotCorrHist2D)
export(plotNbudget)
export(plotRegionMapping)
export(plotRegions)
export(plotUtilization)
export(plotcountrymap)
export(plotmap)
export(plotmap2)
export(plotmap_discrete)
export(plotregionscluster)
export(qualityMeasure)
export(scratch_legend)
export(scratch_plot)
export(showcolors)
export(swoutput)
export(whereplot)
import(magclass)
importFrom(RColorBrewer,brewer.pal)
importFrom(data.table,data.table)
importFrom(dplyr,bind_rows)
importFrom(fields,image.plot)
importFrom(ggplot2,aes)
importFrom(ggplot2,aes_)
importFrom(ggplot2,aes_string)
importFrom(ggplot2,annotate)
importFrom(ggplot2,annotation_raster)
importFrom(ggplot2,coord_cartesian)
importFrom(ggplot2,coord_fixed)
importFrom(ggplot2,coord_flip)
Expand Down Expand Up @@ -71,13 +49,11 @@ importFrom(ggplot2,ggtitle)
importFrom(ggplot2,guide_colorbar)
importFrom(ggplot2,guide_legend)
importFrom(ggplot2,guides)
importFrom(ggplot2,label_wrap_gen)
importFrom(ggplot2,labs)
importFrom(ggplot2,rel)
importFrom(ggplot2,scale_alpha_continuous)
importFrom(ggplot2,scale_alpha_discrete)
importFrom(ggplot2,scale_color_manual)
importFrom(ggplot2,scale_fill_brewer)
importFrom(ggplot2,scale_fill_gradient)
importFrom(ggplot2,scale_fill_gradient2)
importFrom(ggplot2,scale_fill_gradientn)
Expand All @@ -88,46 +64,23 @@ importFrom(ggplot2,scale_x_discrete)
importFrom(ggplot2,scale_y_continuous)
importFrom(ggplot2,scale_y_date)
importFrom(ggplot2,scale_y_discrete)
importFrom(ggplot2,scale_y_log10)
importFrom(ggplot2,scale_y_sqrt)
importFrom(ggplot2,stat_summary)
importFrom(ggplot2,theme)
importFrom(ggplot2,theme_bw)
importFrom(ggplot2,theme_linedraw)
importFrom(ggplot2,unit)
importFrom(ggplot2,waiver)
importFrom(ggplot2,xlab)
importFrom(ggplot2,xlim)
importFrom(ggplot2,ylim)
importFrom(grDevices,col2rgb)
importFrom(grDevices,colorRampPalette)
importFrom(grDevices,dev.new)
importFrom(grDevices,dev.off)
importFrom(grDevices,gray.colors)
importFrom(grDevices,hcl)
importFrom(grDevices,hsv)
importFrom(grDevices,pdf)
importFrom(grDevices,png)
importFrom(grDevices,rgb)
importFrom(grDevices,rgb2hsv)
importFrom(grDevices,terrain.colors)
importFrom(graphics,abline)
importFrom(graphics,axis)
importFrom(graphics,barplot)
importFrom(graphics,grid)
importFrom(graphics,image)
importFrom(graphics,layout)
importFrom(graphics,legend)
importFrom(graphics,lines)
importFrom(graphics,mtext)
importFrom(graphics,par)
importFrom(graphics,plot)
importFrom(graphics,points)
importFrom(graphics,polygon)
importFrom(graphics,text)
importFrom(graphics,title)
importFrom(gridExtra,marrangeGrob)
importFrom(luscale,superAggregate)
importFrom(lusweave,swfigure)
importFrom(lusweave,swtable)
importFrom(magclass,"getNames<-")
Expand All @@ -136,39 +89,30 @@ importFrom(magclass,"getSets<-")
importFrom(magclass,"getYears<-")
importFrom(magclass,as.data.frame)
importFrom(magclass,collapseNames)
importFrom(magclass,dimSums)
importFrom(magclass,fulldim)
importFrom(magclass,getCells)
importFrom(magclass,getNames)
importFrom(magclass,getRegions)
importFrom(magclass,getYears)
importFrom(magclass,is.magpie)
importFrom(magclass,lowpass)
importFrom(magclass,mbind)
importFrom(magclass,ncells)
importFrom(magclass,ndata)
importFrom(magclass,new.magpie)
importFrom(magclass,nyears)
importFrom(magclass,read.magpie)
importFrom(magclass,setCells)
importFrom(magclass,setNames)
importFrom(magclass,setYears)
importFrom(magclass,where)
importFrom(magpiesets,findset)
importFrom(magpiesets,reportingnames)
importFrom(mip,plotstyle)
importFrom(mstools,toolGetMappingCoord2Country)
importFrom(quitte,as.quitte)
importFrom(reshape2,melt)
importFrom(rworldmap,addMapLegendBoxes)
importFrom(rworldmap,joinCountryData2Map)
importFrom(rworldmap,mapCountryData)
importFrom(sp,plot)
importFrom(stats,as.formula)
importFrom(stats,cor)
importFrom(stats,cor.test)
importFrom(stats,na.omit)
importFrom(stats,quantile)
importFrom(stats,reshape)
importFrom(stats,weighted.mean)
importFrom(utils,data)
Expand All @@ -177,8 +121,3 @@ importFrom(utils,methods)
importFrom(utils,read.csv)
importFrom(utils,tail)
importFrom(utils,write.csv2)
importFrom(xml2,"xml_attr<-")
importFrom(xml2,read_xml)
importFrom(xml2,write_xml)
importFrom(xml2,xml_attr)
importFrom(xml2,xml_find_all)
43 changes: 0 additions & 43 deletions R/SVGsankeyNitrogen.R

This file was deleted.

30 changes: 15 additions & 15 deletions R/aggregate_for_plot.R → R/aggregateForPlot.R
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#' aggregate_for_plot
#' aggregateForPlot
#'
#' Aggregates Data for an area chart. The value of all underlying
#' regions/years/timesteps are added to the value of the current
#' region/year/timestep.
#'
#'
#' @usage aggregate_for_plot(plotdata,
#' dimension="region",region_plotorder=NULL)
#' @usage aggregateForPlot(plotdata,
#' dimension="region",regionPlotorder=NULL)
#' @param plotdata An MAgPIE object
#' @param dimension by "region", "name" or "year"
#' @param region_plotorder allows to change the order of the regions by giving
#' @param regionPlotorder allows to change the order of the regions by giving
#' a vector with the order
#' @return A MAgPIE object of the same dimensions as plotdata
#' @author Benjamin Bodirsky
Expand All @@ -19,34 +19,34 @@
#' #no aggregation
#' scratch_plot(population_magpie[,,2])
#' #aggregation
#' scratch_plot(aggregate_for_plot(population_magpie[,,2],region_plotorder=c(10,1:9)))
#' scratch_plot(aggregateForPlot(population_magpie[,,2],regionPlotorder=c(10,1:9)))
#' }
#' @export
#' @importFrom magclass getRegions setCells getCells getNames<- getYears getYears<- getRegions<- getNames

aggregate_for_plot<-function(plotdata, dimension="region", region_plotorder=NULL)
aggregateForPlot<-function(plotdata, dimension="region", regionPlotorder=NULL)
{
#dimension="region"
#data(population_magpie)
#plotdata<-population_magpie
#plot_order=NULL
#region_plotorder=c(1,3,4,5,6,7,8,9,10,2)
if (is.null(region_plotorder)) {
region_plotorder=1:dim(plotdata)[1]
} else if(length(region_plotorder)!=dim(plotdata)[1]){stop("plotorder has to be vector with the length of dim(plotdata)[1]")}
#regionPlotorder=c(1,3,4,5,6,7,8,9,10,2)
if (is.null(regionPlotorder)) {
regionPlotorder=1:dim(plotdata)[1]
} else if(length(regionPlotorder)!=dim(plotdata)[1]){stop("plotorder has to be vector with the length of dim(plotdata)[1]")}
if(magpieResolution(plotdata)=="cell") {stop("Cellular datasets are not supported")}
if (dimension=="region") {
aggregateplotdata<-plotdata[1,,]*0
plotdata_out<-plotdata*0
dimnames(plotdata_out)[[1]]<-paste(getRegions(plotdata)[region_plotorder],1:dim(plotdata)[1],sep=".")
for (region_dimension in getRegions(plotdata)[region_plotorder]) {
dimnames(plotdata_out)[[1]]<-paste(getRegions(plotdata)[regionPlotorder],1:dim(plotdata)[1],sep=".")
for (region_dimension in getRegions(plotdata)[regionPlotorder]) {
plotdata_out[region_dimension,,] <- setCells(aggregateplotdata,getCells(plotdata[region_dimension,,])) + plotdata[region_dimension,,]
aggregateplotdata<-plotdata_out[region_dimension,,]
}
} else if (dimension=="name") {
aggregateplotdata<-plotdata[,,1]*0
for (name_dimension in getNames(plotdata)) {
getNames(aggregate_for_plot) <- name_dimension
getNames(aggregateForPlot) <- name_dimension
plotdata_out[,,name_dimension] <- aggregateplotdata + plotdata[,,name_dimension]
aggregateplotdata<-plotdata_out[,,name_dimension]
}
Expand All @@ -60,8 +60,8 @@ aggregate_for_plot<-function(plotdata, dimension="region", region_plotorder=NULL
} else if (dimension=="region_name") {
aggregateplotdata<-plotdata[1,,1]*0
plotdata_out<-plotdata*0
dimnames(plotdata_out)[[1]]<-paste(getRegions(plotdata)[region_plotorder],1:dim(plotdata)[1],sep=".")
for (region_dimension in getRegions(plotdata)[region_plotorder]) {
dimnames(plotdata_out)[[1]]<-paste(getRegions(plotdata)[regionPlotorder],1:dim(plotdata)[1],sep=".")
for (region_dimension in getRegions(plotdata)[regionPlotorder]) {
getRegions(aggregateplotdata) <- region_dimension
for (name_dimension in getNames(plotdata)) {
plotdata_out[region_dimension,,name_dimension] <- setCells(aggregateplotdata,getCells(plotdata[region_dimension,,])) + plotdata[region_dimension,,name_dimension]
Expand Down
Loading

0 comments on commit 40d0c44

Please sign in to comment.