Learn R Programming

seas (version 0.2-1)

hidden: Get labels and properties for seasonal graphs

Description

Get title, x-axis labels and colours for seasonal graphs. Also, draw the month grid.

Usage

.seasxlab(width)
.seastitle(main=NULL, id=NULL, name=NULL, orig=NULL, fun=NULL,
  range=NA, show.range=TRUE, show.id=TRUE, style=c(1,NA), ...)
.seascols(precip.only=NULL, style=c(NA,1), lwd=NULL, ...)
.seasmonthgrid(month.abb=TRUE, month.len=NULL, month.force=FALSE,
  month.draw=TRUE, width, num, month.col="lightgrey", month.lwd=1, ...)

Arguments

width
size of bin; see mkfact
num
number of bins; if omitted, will calculate from width
main
main title of plot; overrides any other title, but appends year range if show.range=TRUE
id
station ID, which is used to fetch a station name using getstnname
name
a name, which is used in preference to the name retrieved from getstnname
orig
original object name, which is used if no other name can be found from id or name
fun
function, if applicable
range
year range in the format c( start , end ) years
show.range
logical
show.id
logical
style
specified as c(title,colours), which are pre-determined styles for plot, see details below
precip.only
logical; specify if colours need to be produced for precipitation only, or for rain and snow
lwd
line width to be used for plots: for plot.seas.temp, this changes the width of the diurnal variability lines; for image.seas.sum, this
month.abb
logical; abbreviate month names (using the "%b" format), or use the normal month names (using the "%B")
month.len
length of the month names, for instance, will use J-F-M-...(in English locale) if month.len=1
month.force
logical; force month labels to be drawn for each month (uses mtext; labels may overlap); or let axis place labels (default)
month.draw
logical; place month labels (grid will be drawn regardless)
month.col
colour for month grid; default is "lightgrey"
month.lwd
line width for month grid; default is 1
...
not used

Value

  • .seasxlab returns a character label. .seastitle returns a list.

Details

These functions are called by the seasonal plot functions in seas for consistent display of title, x-axis labels and colours. These functions are ready to have translations for non-English languages built into them. Month names currently translate according to your operating system and locale settings. style can be passed to the ... parameter for most plotting functions in seas to modify the look. It can be passed in the format c(title,colours), where each are integers, explained below.

Title styles:

  • 0no title,par(mar)is adjusted to acomodate more space for the figure
  • 1[name] [id] [from start to [end]]
  • 2[name] [id] [ start - [end]](spans two lines)
Colour styles:
  • 0black & white theme: all box-plots are clear, lines are all black, precipitation or snow have a line density fill of 20 and angle of 45, rain has a line density of 10 and an angle of -45
  • 1, colour theme: precipitation or rain arelightblue, snow isgrey, temperature boxplots arelightgrey, diurnal temperature lines arered, wet boxplots arelightblue, dry boxplots areorange, andNAmarks arered
  • 2, grey-scale theme: precipitation or rain aregrey80, snow isgrey60, temperature boxplots aregrey70, diurnal temperature lines aregrey20, wet boxplots aregrey70, dry boxplots aregrey50, andNAmarks aregrey30

Also, other details, such as the back-ground colour, font family, may be adjusted by setting parameters using the par function before plotting. For example, setting par(cex=0.75) will reduce the font size in the active device by 75% of the original size.

See Also

getstnname

Examples

Run this code
par.orig <- par(no.readonly=TRUE)
on.exit(par(par.orig))

.seasxlab(11)
.seasxlab("mon")

data(mscdata)

par(family="serif",cex=1.2)
plot.seas.temp(mscdata, width=11, id=1108447,
  style=c(1,1), month.len=1)

par(family="sans",cex=0.8)
plot.seas.temp(mscdata, width=365/12, id=1108447,
  style=c(2,0), month.abb=FALSE)

par(family="mono",cex=1)
plot.seas.temp(mscdata, width="mon",  id=1108447,
  style=c(0,2))

# make a professional EPS figure for a publication:
postscript("fig2_temperature.eps",
  width=5,height=3,horizontal=FALSE,onefile=TRUE,
  paper="special")
par(cex=0.6,lwd=0.8)
plot.seas.temp(mscdata,id="1108447",style=c(3,2))
dev.off()

Run the code above in your browser using DataLab