Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Franssen, Wietse
WFRTools
Commits
22e3e545
Commit
22e3e545
authored
Apr 13, 2015
by
Franssen, Wietse
Browse files
some minor improvements
parent
237619bc
Changes
2
Hide whitespace changes
Inline
Side-by-side
R/WFRTools.R
View file @
22e3e545
...
...
@@ -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
){
...
...
man/ggplotje.Rd
View file @
22e3e545
...
...
@@ -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}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment