Commit 22e3e545 authored by Franssen, Wietse's avatar Franssen, Wietse
Browse files

some minor improvements

parent 237619bc
......@@ -119,7 +119,9 @@ r2ggplotDataStructure <-function(data, timestep = 1) {
#' @author Wietse Franssen \email{wietse.franssen@@wur.nl}
#' @keywords internal
#' @export
ggplotje <-function(rdata,lon = NULL, lat = NULL) {
ggplotje <-function(rdata,lon = NULL, lat = NULL,title=NULL ) {
if (is.null(title)) {
if (!is.na(rdata$Dates$start[1])) {
# title=paste0(rdata$Variable$longName, " [",rdata$Variable$units,"]\n(" ,rdata$Dates$start[1], ")")
......@@ -127,7 +129,7 @@ ggplotje <-function(rdata,lon = NULL, lat = NULL) {
} else {
title=paste0(rdata$Variable$longName, " [",rdata$Variable$units,"]")
}
}
data<-r2ggplotDataStructure(rdata)
myPalette <- colorRampPalette(rev(brewer.pal(11, "Spectral")), space="Lab")
......@@ -137,8 +139,9 @@ ggplotje <-function(rdata,lon = NULL, lat = NULL) {
aes(x = lon, y = lat, fill = data)) +
ggtitle(title) + # plot title
geom_tile(aes(x = lon, y = lat, fill = data)) +
scale_fill_gradientn(colours = myPalette(100)) +
#zp1 <- zp1 + scale_x_discrete(expand = c(0, 0))
scale_fill_gradientn(colours = myPalette(100)) +
# scale_fill_gradientn(colours = myPalette(100), limits=c(-1,1)) +
#zp1 <- zp1 + scale_x_discrete(expand = c(0, 0))
#zp1 <- zp1 + scale_x_discrete(limits=c(ggdata$lon[1], ggdata$lon[length(ggdata$lon)]))
#zp1 <- zp1 + scale_y_discrete(limits=c(ggdata$lat[1], ggdata$lat[length(ggdata$lat)]))
#zp1 <- zp1 + coord_cartesian(xlim = c(-20, 40),ylim = c(ggdata$lat[1], ggdata$lat[length(ggdata$lat)]))
......@@ -157,6 +160,7 @@ ggplotje <-function(rdata,lon = NULL, lat = NULL) {
zp1 <- zp1 + geom_point( fill="red",colour="black", size = 6, aes_string(x = lon, y = lat, shape=18))
}
print(zp1)
return(zp1)
}
countryMap <- function(lon,lat){
......
......@@ -4,7 +4,7 @@
\alias{ggplotje}
\title{Plot a simple map}
\usage{
ggplotje(rdata, lon = NULL, lat = NULL)
ggplotje(rdata, lon = NULL, lat = NULL, title = NULL)
}
\arguments{
\item{file}{Name of the NetCDF file}
......
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