Commit cd9b2797 authored by Franssen, Wietse's avatar Franssen, Wietse
Browse files

ggplotje: added backgroundColor

parent 2d3dc436
......@@ -5,6 +5,6 @@ Version: 1.0
Date: 2015-02-16
Author: Wietse Franssen
Maintainer: Wietse Franssen <wietse.franssen@wur.nl>
Depends: R (>= 3.0.0), ncdf4, fields, RColorBrewer, ggplot2, udunits2
Depends: R (>= 3.0.0), ncdf4, fields, RColorBrewer, ggplot2, udunits2, scales
Description: Some usefull R-Functions
License: GPL
......@@ -162,7 +162,7 @@ ggplotjeold <-function(rdata,lon = NULL, lat = NULL,title=NULL ) {
print(zp1)
return(zp1)
}
ggplotje <-function(rdata,lon = NULL, lat = NULL,title=NULL, barLimits=NULL, barDiff=FALSE ) {
ggplotje <-function(rdata,lon = NULL, lat = NULL,title=NULL, barLimits=NULL, barDiff=FALSE, backgroudColor=NULL ) {
if (is.null(title)) {
if (!is.na(rdata$Dates$start[1])) {
......@@ -199,16 +199,20 @@ ggplotje <-function(rdata,lon = NULL, lat = NULL,title=NULL, barLimits=NULL, bar
# xlab(expression(Longitude * ' ' * degree * E * ' ')) +
# ylab(expression(Latitude * ' ' * degree * S * ' ')) +
# library(scales)
if (!is.null(backgroudColor)) {
zp1 <- zp1 + theme(panel.background=element_rect(fill=backgroudColor))
}
library(scales)
if (is.null(barLimits)) {
if (barDiff==TRUE) {
zp1 <- zp1 + scale_fill_gradient2(low=muted("red"), high=muted("blue"))
zp1 <- zp1 + scale_fill_gradient2(low=muted("red"), mid=("yellow"),high=muted("blue"))
} else {
zp1 <- zp1 + scale_fill_gradientn(colours = myPalette(100))
}
} else {
if (barDiff==TRUE) {
zp1 <- zp1 + scale_fill_gradient2(limits=barLimits, low=muted("red"), high=muted("blue"))
zp1 <- zp1 + scale_fill_gradient2(limits=barLimits, low=muted("red"),mid=("ghostwhite"), high=muted("blue"))
} else {
zp1 <- zp1 + scale_fill_gradientn(colours = myPalette(100),limits=barLimits)
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment