Here's a fun one. Pretty rainfall plots

3 views
Skip to first unread message

Lauren Hodgson

unread,
Sep 25, 2012, 7:50:41 AM9/25/12
to tropi...@googlegroups.com
Hi all,

I'm working on a bit of a brainteaser at the moment. I need to make
plots of modelled mean annual temperature for each year from 2015 to
2085, for a low and a high 'concentration' scenario. Attached is one
I've prepared earlier. In fact, I have done this for all states, nrm
regions, and ibra regions, and all my temperature graphs look just as
pretty.

Everything was fine...until I tried to do the same for annual rainfall.

The question is, how do I go about generating the same plot with
wildly varying y-limits.

...

The values that from one graph to the next are:

- plot y limits: they need a bit of buffering at the top and bottom.
I solved this for temperature by:
ylim=c(round(ymin-0.5), round(ymax+0.5))
# buffer by 0.5 degrees then round to nearest whole digit

- tick marks along the y axis
eg. axis(2,seq(ylim[1],ylim[2],1) ...)
# on the y axis, add tick marks at every 1 degree between the
sequence of the top and bottom y limits

- number of grid lines on the yaxis (ny)
(those white lines on the grey background)
grid(nx=7, ny=ylim[2]-ylim[1] ...)
# number of grid lines is equal to top ymax - ymin

Obviously, I can't put white lines and tick marks at every 1 mL
different in rainfall when the ymax-ymin might be several hundred mLs!
However, I can't sensibly show the variation a region experiences if
i set the y axis to the total limits of the data: 0 to 8000mL. Some
arid regions are projected to become more arid, and we don't want to
obscure that - the difference between some water and nearly no water
is a big one!

Let me know if you have any thoughts. :D

Lauren
absolute.climate.bioclim_01.png

Keith, Sally

unread,
Sep 25, 2012, 8:02:51 AM9/25/12
to <tropical-r@googlegroups.com>
Log the y values?

Sally A. Keith
ARC CoE Coral Reef Studies
James Cook University
Townsville, QLD 4811
> --
> An R group for questions, tips and tricks relevant to spatial ecology and climate change.
> All R questions welcome.
> ---
> You received this message because you are subscribed to the Google Groups "Tropical R" group.
> To post to this group, send an email to tropi...@googlegroups.com.
> To unsubscribe from this group, send email to tropical-r+...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
> <absolute.climate.bioclim_01.png>

Lauren Hodgson

unread,
Sep 25, 2012, 8:38:04 AM9/25/12
to tropi...@googlegroups.com
The plots are aimed at managers, so I'm trying to show raw values.
Absolute values is the instruction from the boss.

I haven't been able to think of anything other than a bunch of ifelse
conditions at this stage.

I might be lazy and just go with padding the ylims by 10%...then
...round to nearest 1 if ymax-ymin <10
...round to nearest 10 if ymax-ymin >10 <100
...round to nearest 50 if ymax-ymin >100 <500
...round to nearest 100 if ymax-ymin >500

or something messy like that.

Reside, April

unread,
Sep 25, 2012, 8:32:19 PM9/25/12
to tropi...@googlegroups.com
You do such great graphics ...

April Reside
Postdoctoral Research Fellow

Centre for Tropical Biodiversity and Climate Change
School of Marine and Tropical Biology
ATSIP, James Cook University, Townsville, QLD, Australia 4811| Ph: +61 7 4781 5351
http://www.jcu.edu.au/ctbcc/staff/JCU_097396.html
skype: april.reside

Lauren Hodgson

unread,
Sep 25, 2012, 8:46:39 PM9/25/12
to tropi...@googlegroups.com
I ended up doing it the messy lazy way:

padded.limits=function(limits, floor.lim=-Inf, ceiling.lim=Inf) {

ldiff=limits[2]-limits[1]

lmin=limits[1]
lmax=limits[2]

if (ldiff<=2){
lims=c(round(lmin-0.05,1),round(lmax+0.05,1)) } #round to 0.1
if (ldiff>2 & ldiff<=10){
lims=c(round(lmin-0.5),round(lmax+0.5)) }#round to 1
if (ldiff>10 & ldiff<=50){
lims=c(round((lmin-2.5)*2,-1)/2,round((lmax+2.5)*2,-1)/2) }#round to 5
if (ldiff>50 & ldiff<=100){
lims=c(round(lmin-5,-1),round(lmax+5,-1))} #round to 10
if (ldiff>100 & ldiff<=200){
lims=c(round((lmin-10)*5,-2)/5,round((lmax+10)*5,-2)/5) }#round to 20
if (ldiff>200 & ldiff<=500) {
lims=c(round((lmin-25)*2,-2)/2,round((lmax+25)*2,-2)/2) }#round to 50
if (ldiff>500) {
lims=c(round(lmin-50,-2)/2,round(lmax+50,-2)/2) }#round to 100

if (lims[1]<floor.lim) { lims[1]=floor.lim }
if (lims[2]>ceiling.lim) { lims[2]=ceiling.lim }

return(lims)}

## eg. ylim=padded.limits(limits,floor.lim=0)
Reply all
Reply to author
Forward
0 new messages