[R] Polar graph of time and tide
Jim Lemon
jim at bitwrit.com.au
Wed May 2 12:52:59 CEST 2007
Alan E. Davis wrote:
> I have been trying to visualize times of lowest tides, month by month.
> I have tide predictions with times either in unix time or a text
> format, and heights in feet or meters. I had been able to derive the
> clock times of each prediction. I would now like to graph this data
> with points showing heights as "r" and times as "theta", from 0000 to
> 2355. There is a seasonal component: I am interested in displaying
> times of lowest tides in particular.
>
> I am sure this is so simple as to burden those on the list; I however
> have spent two evenings trying to figure out how to use polar.plot,
> and I'm not sure that's the best way to do this. May I request some
> advice? The docs with polar.plot are not complete, I fear.
>
> Thank you, begging for your indulgence,
>
Hi Alan,
Earl Glynn's advice is spot-on if you are trying to map tides onto the
diurnal cycle. However, I get the impression that you want an annual
cycle. If this is the case, it is probably best to go to the underlying
function, radial.plot. Here is an example with some imaginary tides.
lowtide<-sin(seq(1:12)+sin(seq(1,24,by=2)/10))
lowtide<-rescale(lowtide,c(0,2355))
month.abbr<-c("jan","Feb","Mar","Apr","May","Jun",
"Jul","Aug","Sep","Oct","Nov","Dec")
radial.plot(lowtide,labels=month.abbr,rp.type="s")
This plots time of lowest tide in a month as a symbol at a radial
distance proportional to the 24 hour time of day. As you can see from
running the example, the months of the year are displayed around the
circumference of the plot. One annoyance is that the hours are displayed
as 0-2500. As "pretty" handles that, you would have to set
show.radial.grid to FALSE and manually draw the desired grid (a pain,
but not impossible).
You could also place the symbols at the position in the month of the
lowest tide by specifying radial.pos instead of letting the function
spread them out evenly.
If you want to overlay a number of years, x should be a matrix and
point.col can be chosen so that each year has a different color.
I would like to know of any deficiencies in the docs, as while I think I
know what I'm talking about, it is you out there who have to understand it.
Jim
More information about the R-help
mailing list