guides(fill=guide_legend(title='Mitigation measures')) # Colour theme, x and y labels, and changing the title of the legend int<- p2int+theme_clean()+ scale_fill_economist()+ ylab('Marginal Abatement Cost (EUR/t)')+ xlab('CO2-eq Emissions Reduction (1000 t)')+ guides(fill=guide_legend(title=NULL)) # Colour theme, x and y labels, and changing the title of the legend ext<- p2ext+theme_clean()+ scale_fill_economist()+ ylab('Marginal Abatement Cost (EUR/t)')+ xlab('CO2-eq Emissions Reduction (1000 t)')+ guides(fill=guide_legend(title=NULL)) # Colour theme, x and y labels, and changing the title of the legend sand<- p2sand+theme_clean()+ scale_fill_economist()+ ylab('Marginal Abatement Cost (EUR/t)')+ xlab('CO2-eq Emissions Reduction (1000 t)')+ guides(fill=guide_legend(title=NULL)) # Colour theme, x and y labels, and changing the title of the legend clay<- p2clay+theme_clean()+ scale_fill_economist()+ ylab('Marginal Abatement Cost (EUR/t)')+ xlab('CO2-eq Emissions Reduction (1000 t)')+ guides(fill=guide_legend(title=NULL,title.theme =NULL)) # Colour theme, x and y labels, and changing the title of the legend ggarrange(int, ext, sand, clay, common.legend = TRUE, legend = 'bottom') ggsave('gridmacplot', device = 'jpg') ggsave('\FARMDYNDATA\gridmacplot', device = 'jpg') ggsave('/FARMDYNDATA/gridmacplot', device = 'jpg') ggsave('C:/FARMDYNDATA/gridmacplot', device = 'jpg') p2ext <- p1ext + geom_text(aes(x=wt, y=MAC+15, label=scales::percent(pct)), position = position_dodge(width = .9), # move to center of bars size = 3 ) + ggtitle('Extensive farm') p2sand <- p1sand + geom_text(aes(x=wt, y=MAC+15, label=scales::percent(pct)), position = position_dodge(width = .9), # move to center of bars size = 3 )+ggtitle('Sandy Soil') p2clay <- p1clay + geom_text(aes(x=wt, y=MAC+15, label=scales::percent(pct)), position = position_dodge(width = .9), # move to center of bars size = 3 )+ggtitle('Clay Soil') total<- p2total+theme_clean()+ scale_fill_economist()+ ylab('Marginal Abatement Cost (EUR/t)')+ xlab('CO2-eq Emissions Reduction (1000 t)')+ guides(fill=guide_legend(title='Mitigation measures')) # Colour theme, x and y labels, and changing the title of the legend int<- p2int+theme_clean()+ scale_fill_economist()+ ylab('Marginal Abatement Cost (EUR/t)')+ xlab('CO2-eq Emissions Reduction (1000 t)')+ guides(fill=guide_legend(title=NULL)) # Colour theme, x and y labels, and changing the title of the legend ext<- p2ext+theme_clean()+ scale_fill_economist()+ ylab('Marginal Abatement Cost (EUR/t)')+ xlab('CO2-eq Emissions Reduction (1000 t)')+ guides(fill=guide_legend(title=NULL)) # Colour theme, x and y labels, and changing the title of the legend sand<- p2sand+theme_clean()+ scale_fill_economist()+ ylab('Marginal Abatement Cost (EUR/t)')+ xlab('CO2-eq Emissions Reduction (1000 t)')+ guides(fill=guide_legend(title=NULL)) # Colour theme, x and y labels, and changing the title of the legend clay<- p2clay+theme_clean()+ scale_fill_economist()+ ylab('Marginal Abatement Cost (EUR/t)')+ xlab('CO2-eq Emissions Reduction (1000 t)')+ guides(fill=guide_legend(title=NULL,title.theme =NULL)) # Colour theme, x and y labels, and changing the title of the legend ggarrange(int, ext, sand, clay, common.legend = TRUE, legend = 'bottom') p2int <- p1int + geom_text(aes(x=wt, y=MAC+10, label=scales::percent(pct)), position = position_dodge(width = .9), # move to center of bars size = 3 )+ ggtitle('Intensive farm') p2ext <- p1ext + geom_text(aes(x=wt, y=MAC+15, label=scales::percent(pct)), position = position_dodge(width = .9), # move to center of bars size = 3 ) + ggtitle('Extensive farm') p2sand <- p1sand + geom_text(aes(x=wt, y=MAC+15, label=scales::percent(pct)), position = position_dodge(width = .9), # move to center of bars size = 3 )+ggtitle('Sandy Soil') p2clay <- p1clay + geom_text(aes(x=wt, y=MAC+15, label=scales::percent(pct)), position = position_dodge(width = .9), # move to center of bars size = 3 )+ggtitle('Clay Soil') total<- p2total+theme_clean()+ scale_fill_economist()+ ylab('Marginal Abatement Cost (EUR/t)')+ xlab('CO2-eq Emissions Reduction (1000 t)')+ guides(fill=guide_legend(title='Mitigation measures')) # Colour theme, x and y labels, and changing the title of the legend int<- p2int+theme_clean()+ scale_fill_economist()+ ylab('Marginal Abatement Cost (EUR/t)')+ xlab('CO2-eq Emissions Reduction (1000 t)')+ guides(fill=guide_legend(title=NULL)) # Colour theme, x and y labels, and changing the title of the legend ext<- p2ext+theme_clean()+ scale_fill_economist()+ ylab('Marginal Abatement Cost (EUR/t)')+ xlab('CO2-eq Emissions Reduction (1000 t)')+ guides(fill=guide_legend(title=NULL)) # Colour theme, x and y labels, and changing the title of the legend sand<- p2sand+theme_clean()+ scale_fill_economist()+ ylab('Marginal Abatement Cost (EUR/t)')+ xlab('CO2-eq Emissions Reduction (1000 t)')+ guides(fill=guide_legend(title=NULL)) # Colour theme, x and y labels, and changing the title of the legend clay<- p2clay+theme_clean()+ scale_fill_economist()+ ylab('Marginal Abatement Cost (EUR/t)')+ xlab('CO2-eq Emissions Reduction (1000 t)')+ guides(fill=guide_legend(title=NULL,title.theme =NULL)) # Colour theme, x and y labels, and changing the title of the legend ggarrange(int, ext, sand, clay, common.legend = TRUE, legend = 'bottom') p2ext <- p1ext + geom_text(aes(x=wt, y=MAC+18, label=scales::percent(pct)), position = position_dodge(width = .9), # move to center of bars size = 3 ) + ggtitle('Extensive farm') p2sand <- p1sand + geom_text(aes(x=wt, y=MAC+15, label=scales::percent(pct)), position = position_dodge(width = .9), # move to center of bars size = 3 )+ggtitle('Sandy Soil') p2clay <- p1clay + geom_text(aes(x=wt, y=MAC+15, label=scales::percent(pct)), position = position_dodge(width = .9), # move to center of bars size = 3 )+ggtitle('Clay Soil') total<- p2total+theme_clean()+ scale_fill_economist()+ ylab('Marginal Abatement Cost (EUR/t)')+ xlab('CO2-eq Emissions Reduction (1000 t)')+ guides(fill=guide_legend(title='Mitigation measures')) # Colour theme, x and y labels, and changing the title of the legend int<- p2int+theme_clean()+ scale_fill_economist()+ ylab('Marginal Abatement Cost (EUR/t)')+ xlab('CO2-eq Emissions Reduction (1000 t)')+ guides(fill=guide_legend(title=NULL)) # Colour theme, x and y labels, and changing the title of the legend ext<- p2ext+theme_clean()+ scale_fill_economist()+ ylab('Marginal Abatement Cost (EUR/t)')+ xlab('CO2-eq Emissions Reduction (1000 t)')+ guides(fill=guide_legend(title=NULL)) # Colour theme, x and y labels, and changing the title of the legend sand<- p2sand+theme_clean()+ scale_fill_economist()+ ylab('Marginal Abatement Cost (EUR/t)')+ xlab('CO2-eq Emissions Reduction (1000 t)')+ guides(fill=guide_legend(title=NULL)) # Colour theme, x and y labels, and changing the title of the legend clay<- p2clay+theme_clean()+ scale_fill_economist()+ ylab('Marginal Abatement Cost (EUR/t)')+ xlab('CO2-eq Emissions Reduction (1000 t)')+ guides(fill=guide_legend(title=NULL,title.theme =NULL)) # Colour theme, x and y labels, and changing the title of the legend ggarrange(int, ext, sand, clay, common.legend = TRUE, legend = 'bottom') p2ext <- p1ext + geom_text(aes(x=wt, y=MAC+20, label=scales::percent(pct)), position = position_dodge(width = .9), # move to center of bars size = 3 ) + ggtitle('Extensive farm') p2sand <- p1sand + geom_text(aes(x=wt, y=MAC+15, label=scales::percent(pct)), position = position_dodge(width = .9), # move to center of bars size = 3 )+ggtitle('Sandy Soil') p2clay <- p1clay + geom_text(aes(x=wt, y=MAC+15, label=scales::percent(pct)), position = position_dodge(width = .9), # move to center of bars size = 3 )+ggtitle('Clay Soil') total<- p2total+theme_clean()+ scale_fill_economist()+ ylab('Marginal Abatement Cost (EUR/t)')+ xlab('CO2-eq Emissions Reduction (1000 t)')+ guides(fill=guide_legend(title='Mitigation measures')) # Colour theme, x and y labels, and changing the title of the legend int<- p2int+theme_clean()+ scale_fill_economist()+ ylab('Marginal Abatement Cost (EUR/t)')+ xlab('CO2-eq Emissions Reduction (1000 t)')+ guides(fill=guide_legend(title=NULL)) # Colour theme, x and y labels, and changing the title of the legend ext<- p2ext+theme_clean()+ scale_fill_economist()+ ylab('Marginal Abatement Cost (EUR/t)')+ xlab('CO2-eq Emissions Reduction (1000 t)')+ guides(fill=guide_legend(title=NULL)) # Colour theme, x and y labels, and changing the title of the legend sand<- p2sand+theme_clean()+ scale_fill_economist()+ ylab('Marginal Abatement Cost (EUR/t)')+ xlab('CO2-eq Emissions Reduction (1000 t)')+ guides(fill=guide_legend(title=NULL)) # Colour theme, x and y labels, and changing the title of the legend clay<- p2clay+theme_clean()+ scale_fill_economist()+ ylab('Marginal Abatement Cost (EUR/t)')+ xlab('CO2-eq Emissions Reduction (1000 t)')+ guides(fill=guide_legend(title=NULL,title.theme =NULL)) # Colour theme, x and y labels, and changing the title of the legend ggarrange(int, ext, sand, clay, common.legend = TRUE, legend = 'bottom') setwd('/Users/Desktop') setwd('/Users/scher043/Desktop') setwd setwd('C:/Users/scher043/Desktop') # Author: Hugo Scherer # Purpose: Create graphs from FarmDyn output of the different scens with 50-150 euro/t carbon taxes and feed adds # Version: 0.0.0 # Date: 17/10/2022 # Notes: # # Copyright(c) 2022 Wageningen Economic Research # ------------------------------------- # PREAMBLE ---- # Load libraries library(tidyverse) library(gdxrrw) library(readxl) library(ggthemes) library(ggpubr) library(gridExtra) ctdatatotal <- read_xlsx('ctdata.xlsx', sheet = 'total') getwd() setwd("//wurnet.nl/Homes/scher043/AppData/FolderRedirection/Desktop") ctdatatotal <- read_xlsx('ctdata.xlsx', sheet = 'total') ctdatatotal <- read_xlsx('ctdata.xlsx', sheet = 'total') ctdataintensive <- read_xlsx('ctdata.xlsx', sheet = 'intensive') ctdataextensive <- read_xlsx('ctdata.xlsx', sheet = 'extensive') ctdatasand <- read_xlsx('ctdata.xlsx', sheet = 'sand') ctdataclay <- read_xlsx('ctdata.xlsx', sheet = 'clay') ctdatapeat <- read_xlsx('ctdata.xlsx', sheet = 'clay') colnames(ctdatatotal)[1] <- 'Mitigation Strategy' colnames(ctdataintensive)[1] <- 'Mitigation Strategy' colnames(ctdataextensive)[1] <- 'Mitigation Strategy' colnames(ctdatasand)[1] <- 'Mitigation Strategy' colnames(ctdataclay)[1] <- 'Mitigation Strategy' colnames(ctdatapeat)[1] <- 'Mitigation Strategy' ctdatatotal$w <- cumsum(ctdatatotal$`CO2-eq emission reduction`) # Calculating cumulative sum of the widths ctdataextensive$w <- cumsum(ctdataextensive$`CO2-eq emission reduction`) # Calculating cumulative sum of the widths ctdataintensive$w <- cumsum(ctdataintensive$`CO2-eq emission reduction`) # Calculating cumulative sum of the widths ctdatasand$w <- cumsum(ctdatasand$`CO2-eq emission reduction`) # Calculating cumulative sum of the widths ctdataclay$w <- cumsum(ctdataclay$`CO2-eq emission reduction`) # Calculating cumulative sum of the widths ctdatapeat$w <- cumsum(ctdatapeat$`CO2-eq emission reduction`) # Calculating cumulative sum of the widths ctdatapeat$pct <- prop.table(ctdatapeat$`CO2-eq emission reduction`) ctdatapeat$wm <- ctdatapeat$w - ctdatapeat$`CO2-eq emission reduction` # Calculation of minimum width (where the rectangle starts) ctdatapeat$wt <- with(ctdatapeat, wm+(w-wm)/2) # Calculation of the middle of the rectangle to position the text pcpeat <- ggplot(ctdatapeat, aes(ymin=0)) # Starting the plotting with a y axis minimum value of 0 ppeat <- ggplot(ctdatapeat, aes(ymin=0)) # Starting the plotting with a y axis minimum value of 0 p1peat <- ppeat + geom_rect(aes(xmin=wm, xmax=w, ymax=MAC, fill=`Mitigation Strategy`)) # Adding the previously calculated parameters to the plot, change colours based on the mitigation strategy p2total <- p1total + geom_text(aes(x=wt, y=MAC+8, label=scales::percent(pct)), position = position_dodge(width = .9), # move to center of bars size = 3 )+ggtitle('Total') p2int <- p1int + geom_text(aes(x=wt, y=MAC+10, label=scales::percent(pct)), position = position_dodge(width = .9), # move to center of bars size = 3 )+ ggtitle('Intensive farm') p2ext <- p1ext + geom_text(aes(x=wt, y=MAC+20, label=scales::percent(pct)), position = position_dodge(width = .9), # move to center of bars size = 3 ) + ggtitle('Extensive farm') p2sand <- p1sand + geom_text(aes(x=wt, y=MAC+15, label=scales::percent(pct)), position = position_dodge(width = .9), # move to center of bars size = 3 )+ggtitle('Sandy Soil') p2clay <- p1clay + geom_text(aes(x=wt, y=MAC+15, label=scales::percent(pct)), position = position_dodge(width = .9), # move to center of bars size = 3 )+ggtitle('Clay Soil') p1total <- ptotal + geom_rect(aes(xmin=wm, xmax=w, ymax=MAC, fill=`Mitigation Strategy`)) # Adding the previously calculated parameters to the plot, change colours based on the mitigation strategy p1ext <- pext + geom_rect(aes(xmin=wm, xmax=w, ymax=MAC, fill=`Mitigation Strategy`)) # Adding the previously calculated parameters to the plot, change colours based on the mitigation strategy p1int <- pint + geom_rect(aes(xmin=wm, xmax=w, ymax=MAC, fill=`Mitigation Strategy`)) # Adding the previously calculated parameters to the plot, change colours based on the mitigation strategy ptotal <- ggplot(ctdatatotal, aes(ymin=0)) # Starting the plotting with a y axis minimum value of 0 pext <- ggplot(ctdataextensive, aes(ymin=0)) # Starting the plotting with a y axis minimum value of 0 pint <- ggplot(ctdataintensive, aes(ymin=0)) # Starting the plotting with a y axis minimum value of 0 psand <- ggplot(ctdatasand, aes(ymin=0)) # Starting the plotting with a y axis minimum value of 0 pclay <- ggplot(ctdataclay, aes(ymin=0)) # Starting the plotting with a y axis minimum value of 0 ppeat <- ggplot(ctdatapeat, aes(ymin=0)) # Starting the plotting with a y axis minimum value of 0 p1total <- ptotal + geom_rect(aes(xmin=wm, xmax=w, ymax=MAC, fill=`Mitigation Strategy`)) # Adding the previously calculated parameters to the plot, change colours based on the mitigation strategy p1ext <- pext + geom_rect(aes(xmin=wm, xmax=w, ymax=MAC, fill=`Mitigation Strategy`)) # Adding the previously calculated parameters to the plot, change colours based on the mitigation strategy p1int <- pint + geom_rect(aes(xmin=wm, xmax=w, ymax=MAC, fill=`Mitigation Strategy`)) # Adding the previously calculated parameters to the plot, change colours based on the mitigation strategy p1sand <- psand + geom_rect(aes(xmin=wm, xmax=w, ymax=MAC, fill=`Mitigation Strategy`)) # Adding the previously calculated parameters to the plot, change colours based on the mitigation strategy p1clay <- pclay + geom_rect(aes(xmin=wm, xmax=w, ymax=MAC, fill=`Mitigation Strategy`)) # Adding the previously calculated parameters to the plot, change colours based on the mitigation strategy p1peat <- ppeat + geom_rect(aes(xmin=wm, xmax=w, ymax=MAC, fill=`Mitigation Strategy`)) # Adding the previously calculated parameters to the plot, change colours based on the mitigation strategy p2total <- p1total + geom_text(aes(x=wt, y=MAC+8, label=scales::percent(pct)), position = position_dodge(width = .9), # move to center of bars size = 3 )+ggtitle('Total') p2int <- p1int + geom_text(aes(x=wt, y=MAC+10, label=scales::percent(pct)), position = position_dodge(width = .9), # move to center of bars size = 3 )+ ggtitle('Intensive farm') p2ext <- p1ext + geom_text(aes(x=wt, y=MAC+20, label=scales::percent(pct)), position = position_dodge(width = .9), # move to center of bars size = 3 ) + ggtitle('Extensive farm') p2sand <- p1sand + geom_text(aes(x=wt, y=MAC+15, label=scales::percent(pct)), position = position_dodge(width = .9), # move to center of bars size = 3 )+ggtitle('Sandy Soil') p2clay <- p1clay + geom_text(aes(x=wt, y=MAC+15, label=scales::percent(pct)), position = position_dodge(width = .9), # move to center of bars size = 3 )+ggtitle('Clay Soil') p2peat <- p1peat + geom_text(aes(x=wt, y=MAC+15, label=scales::percent(pct)), position = position_dodge(width = .9), # move to center of bars size = 3 )+ggtitle('Peat Soil') total<- p2total+theme_clean()+ scale_fill_economist()+ ylab('Marginal Abatement Cost (EUR/t)')+ xlab('CO2-eq Emissions Reduction (1000 t)')+ guides(fill=guide_legend(title='Mitigation measures')) # Colour theme, x and y labels, and changing the title of the legend int<- p2int+theme_clean()+ scale_fill_economist()+ ylab('Marginal Abatement Cost (EUR/t)')+ xlab('CO2-eq Emissions Reduction (1000 t)')+ guides(fill=guide_legend(title=NULL)) # Colour theme, x and y labels, and changing the title of the legend ext<- p2ext+theme_clean()+ scale_fill_economist()+ ylab('Marginal Abatement Cost (EUR/t)')+ xlab('CO2-eq Emissions Reduction (1000 t)')+ guides(fill=guide_legend(title=NULL)) # Colour theme, x and y labels, and changing the title of the legend sand<- p2sand+theme_clean()+ scale_fill_economist()+ ylab('Marginal Abatement Cost (EUR/t)')+ xlab('CO2-eq Emissions Reduction (1000 t)')+ guides(fill=guide_legend(title=NULL)) # Colour theme, x and y labels, and changing the title of the legend clay<- p2clay+theme_clean()+ scale_fill_economist()+ ylab('Marginal Abatement Cost (EUR/t)')+ xlab('CO2-eq Emissions Reduction (1000 t)')+ guides(fill=guide_legend(title=NULL,title.theme =NULL)) # Colour theme, x and y labels, and changing the title of the legend peat<- p2peat+theme_clean()+ scale_fill_economist()+ ylab('Marginal Abatement Cost (EUR/t)')+ xlab('CO2-eq Emissions Reduction (1000 t)')+ guides(fill=guide_legend(title=NULL,title.theme =NULL)) # Colour theme, x and y labels, and changing the title of the legend peat ggarrange(total, int, ext, sand, clay, peat, common.legend = TRUE, legend = 'bottom') ctdatatotal <- read_xlsx('ctdata.xlsx', sheet = 'total') ctdataintensive <- read_xlsx('ctdata.xlsx', sheet = 'intensive') ctdataextensive <- read_xlsx('ctdata.xlsx', sheet = 'extensive') ctdatasand <- read_xlsx('ctdata.xlsx', sheet = 'sand') ctdataclay <- read_xlsx('ctdata.xlsx', sheet = 'clay') ctdatapeat <- read_xlsx('ctdata.xlsx', sheet = 'clay') colnames(ctdatatotal)[1] <- 'Mitigation Strategy' colnames(ctdataintensive)[1] <- 'Mitigation Strategy' colnames(ctdataextensive)[1] <- 'Mitigation Strategy' colnames(ctdatasand)[1] <- 'Mitigation Strategy' colnames(ctdataclay)[1] <- 'Mitigation Strategy' colnames(ctdatapeat)[1] <- 'Mitigation Strategy' ctdatatotal$w <- cumsum(ctdatatotal$`CO2-eq emission reduction`) # Calculating cumulative sum of the widths ctdataextensive$w <- cumsum(ctdataextensive$`CO2-eq emission reduction`) # Calculating cumulative sum of the widths ctdataintensive$w <- cumsum(ctdataintensive$`CO2-eq emission reduction`) # Calculating cumulative sum of the widths ctdatasand$w <- cumsum(ctdatasand$`CO2-eq emission reduction`) # Calculating cumulative sum of the widths ctdataclay$w <- cumsum(ctdataclay$`CO2-eq emission reduction`) # Calculating cumulative sum of the widths ctdatapeat$w <- cumsum(ctdatapeat$`CO2-eq emission reduction`) # Calculating cumulative sum of the widths ctdatatotal$pct <- prop.table(ctdatatotal$`CO2-eq emission reduction`) ctdataintensive$pct <- prop.table(ctdataintensive$`CO2-eq emission reduction`) ctdataextensive$pct <- prop.table(ctdataextensive$`CO2-eq emission reduction`) ctdatasand$pct <- prop.table(ctdatasand$`CO2-eq emission reduction`) ctdataclay$pct <- prop.table(ctdataclay$`CO2-eq emission reduction`) ctdatapeat$pct <- prop.table(ctdatapeat$`CO2-eq emission reduction`) ctdatatotal$wm <- ctdatatotal$w - ctdatatotal$`CO2-eq emission reduction` # Calculation of minimum width (where the rectangle starts) ctdataintensive$wm <- ctdataintensive$w - ctdataintensive$`CO2-eq emission reduction` # Calculation of minimum width (where the rectangle starts) ctdataextensive$wm <- ctdataextensive$w - ctdataextensive$`CO2-eq emission reduction` # Calculation of minimum width (where the rectangle starts) ctdatasand$wm <- ctdatasand$w - ctdatasand$`CO2-eq emission reduction` # Calculation of minimum width (where the rectangle starts) ctdataclay$wm <- ctdataclay$w - ctdataclay$`CO2-eq emission reduction` # Calculation of minimum width (where the rectangle starts) ctdatapeat$wm <- ctdatapeat$w - ctdatapeat$`CO2-eq emission reduction` # Calculation of minimum width (where the rectangle starts) ctdatatotal$wt <- with(ctdatatotal, wm+(w-wm)/2) # Calculation of the middle of the rectangle to position the text ctdataintensive$wt <- with(ctdataintensive, wm+(w-wm)/2) # Calculation of the middle of the rectangle to position the text ctdataextensive$wt <- with(ctdataextensive, wm+(w-wm)/2) # Calculation of the middle of the rectangle to position the text ctdatasand$wt <- with(ctdatasand, wm+(w-wm)/2) # Calculation of the middle of the rectangle to position the text ctdataclay$wt <- with(ctdataclay, wm+(w-wm)/2) # Calculation of the middle of the rectangle to position the text ctdatapeat$wt <- with(ctdatapeat, wm+(w-wm)/2) # Calculation of the middle of the rectangle to position the text ptotal <- ggplot(ctdatatotal, aes(ymin=0)) # Starting the plotting with a y axis minimum value of 0 pext <- ggplot(ctdataextensive, aes(ymin=0)) # Starting the plotting with a y axis minimum value of 0 pint <- ggplot(ctdataintensive, aes(ymin=0)) # Starting the plotting with a y axis minimum value of 0 psand <- ggplot(ctdatasand, aes(ymin=0)) # Starting the plotting with a y axis minimum value of 0 pclay <- ggplot(ctdataclay, aes(ymin=0)) # Starting the plotting with a y axis minimum value of 0 ppeat <- ggplot(ctdatapeat, aes(ymin=0)) # Starting the plotting with a y axis minimum value of 0 p1total <- ptotal + geom_rect(aes(xmin=wm, xmax=w, ymax=MAC, fill=`Mitigation Strategy`)) # Adding the previously calculated parameters to the plot, change colours based on the mitigation strategy p1ext <- pext + geom_rect(aes(xmin=wm, xmax=w, ymax=MAC, fill=`Mitigation Strategy`)) # Adding the previously calculated parameters to the plot, change colours based on the mitigation strategy p1int <- pint + geom_rect(aes(xmin=wm, xmax=w, ymax=MAC, fill=`Mitigation Strategy`)) # Adding the previously calculated parameters to the plot, change colours based on the mitigation strategy p1sand <- psand + geom_rect(aes(xmin=wm, xmax=w, ymax=MAC, fill=`Mitigation Strategy`)) # Adding the previously calculated parameters to the plot, change colours based on the mitigation strategy p1clay <- pclay + geom_rect(aes(xmin=wm, xmax=w, ymax=MAC, fill=`Mitigation Strategy`)) # Adding the previously calculated parameters to the plot, change colours based on the mitigation strategy p1peat <- ppeat + geom_rect(aes(xmin=wm, xmax=w, ymax=MAC, fill=`Mitigation Strategy`)) # Adding the previously calculated parameters to the plot, change colours based on the mitigation strategy p2total <- p1total + geom_text(aes(x=wt, y=MAC+8, label=scales::percent(pct)), position = position_dodge(width = .9), # move to center of bars size = 3 )+ggtitle('Total') p2int <- p1int + geom_text(aes(x=wt, y=MAC+10, label=scales::percent(pct)), position = position_dodge(width = .9), # move to center of bars size = 3 )+ ggtitle('Intensive farm') p2ext <- p1ext + geom_text(aes(x=wt, y=MAC+20, label=scales::percent(pct)), position = position_dodge(width = .9), # move to center of bars size = 3 ) + ggtitle('Extensive farm') p2sand <- p1sand + geom_text(aes(x=wt, y=MAC+15, label=scales::percent(pct)), position = position_dodge(width = .9), # move to center of bars size = 3 )+ggtitle('Sandy Soil') p2clay <- p1clay + geom_text(aes(x=wt, y=MAC+15, label=scales::percent(pct)), position = position_dodge(width = .9), # move to center of bars size = 3 )+ggtitle('Clay Soil') p2peat <- p1peat + geom_text(aes(x=wt, y=MAC+15, label=scales::percent(pct)), position = position_dodge(width = .9), # move to center of bars size = 3 )+ggtitle('Peat Soil') total<- p2total+theme_clean()+ scale_fill_economist()+ ylab('Marginal Abatement Cost (EUR/t)')+ xlab('CO2-eq Emissions Reduction (1000 t)')+ guides(fill=guide_legend(title='Mitigation measures')) # Colour theme, x and y labels, and changing the title of the legend int<- p2int+theme_clean()+ scale_fill_economist()+ ylab('Marginal Abatement Cost (EUR/t)')+ xlab('CO2-eq Emissions Reduction (1000 t)')+ guides(fill=guide_legend(title=NULL)) # Colour theme, x and y labels, and changing the title of the legend ext<- p2ext+theme_clean()+ scale_fill_economist()+ ylab('Marginal Abatement Cost (EUR/t)')+ xlab('CO2-eq Emissions Reduction (1000 t)')+ guides(fill=guide_legend(title=NULL)) # Colour theme, x and y labels, and changing the title of the legend sand<- p2sand+theme_clean()+ scale_fill_economist()+ ylab('Marginal Abatement Cost (EUR/t)')+ xlab('CO2-eq Emissions Reduction (1000 t)')+ guides(fill=guide_legend(title=NULL)) # Colour theme, x and y labels, and changing the title of the legend clay<- p2clay+theme_clean()+ scale_fill_economist()+ ylab('Marginal Abatement Cost (EUR/t)')+ xlab('CO2-eq Emissions Reduction (1000 t)')+ guides(fill=guide_legend(title=NULL,title.theme =NULL)) # Colour theme, x and y labels, and changing the title of the legend peat<- p2peat+theme_clean()+ scale_fill_economist()+ ylab('Marginal Abatement Cost (EUR/t)')+ xlab('CO2-eq Emissions Reduction (1000 t)')+ guides(fill=guide_legend(title=NULL,title.theme =NULL)) # Colour theme, x and y labels, and changing the title of the legend ggarrange(total, int, ext, sand, clay, peat, common.legend = TRUE, legend = 'bottom') peat peat<- p2peat+theme_clean()+ scale_fill_economist()+ ylab('Marginal Abatement Cost (EUR/t)')+ xlab('CO2-eq Emissions Reduction (1000 t)')+ guides(fill=guide_legend(title='Mitigation measures')) # Colour theme, x and y labels, and changing the title of the legend peat total<- p2total+theme_clean()+ scale_fill_economist()+ ylab('Marginal Abatement Cost (EUR/t)')+ xlab('CO2-eq Emissions Reduction (1000 t)')+ guides(fill=guide_legend(title='Mitigation measures')) # Colour theme, x and y labels, and changing the title of the legend int<- p2int+theme_clean()+ scale_fill_economist()+ ylab('Marginal Abatement Cost (EUR/t)')+ xlab('CO2-eq Emissions Reduction (1000 t)')+ guides(fill=guide_legend(title='Mitigation measures')) # Colour theme, x and y labels, and changing the title of the legend ext<- p2ext+theme_clean()+ scale_fill_economist()+ ylab('Marginal Abatement Cost (EUR/t)')+ xlab('CO2-eq Emissions Reduction (1000 t)')+ guides(fill=guide_legend(title='Mitigation measures')) # Colour theme, x and y labels, and changing the title of the legend sand<- p2sand+theme_clean()+ scale_fill_economist()+ ylab('Marginal Abatement Cost (EUR/t)')+ xlab('CO2-eq Emissions Reduction (1000 t)')+ guides(fill=guide_legend(title='Mitigation measures')) # Colour theme, x and y labels, and changing the title of the legend clay<- p2clay+theme_clean()+ scale_fill_economist()+ ylab('Marginal Abatement Cost (EUR/t)')+ xlab('CO2-eq Emissions Reduction (1000 t)')+ guides(fill=guide_legend(title='Mitigation measures'L)) # Colour theme, x and y labels, and changing the title of the legend peat<- p2peat+theme_clean()+ scale_fill_economist()+ ylab('Marginal Abatement Cost (EUR/t)')+ xlab('CO2-eq Emissions Reduction (1000 t)')+ guides(fill=guide_legend(title='Mitigation measures')) # Colour theme, x and y labels, and changing the title of the legend ggarrange(total, int, ext, sand, clay, peat, common.legend = TRUE, legend = 'bottom') clay<- p2clay+theme_clean()+ scale_fill_economist()+ ylab('Marginal Abatement Cost (EUR/t)')+ xlab('CO2-eq Emissions Reduction (1000 t)')+ guides(fill=guide_legend(title='Mitigation measures')) # Colour theme, x and y labels, and changing the title of the legend peat<- p2peat+theme_clean()+ scale_fill_economist()+ ylab('Marginal Abatement Cost (EUR/t)')+ xlab('CO2-eq Emissions Reduction (1000 t)')+ guides(fill=guide_legend(title='Mitigation measures')) # Colour theme, x and y labels, and changing the title of the legend int ggsave('intmacplot.jpg', device = 'jpg') ext ggsave('extmacplot.jpg', device = 'jpg') sand ggsave('sandmacplot.jpg', device = 'jpg') clay ggsave('claymacplot.jpg', device = 'jpg') peat ggsave('peatmacplot.jpg', device = 'jpg')