polar.plot text labels for data points

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

polar.plot text labels for data points

Tali
Hello All.

I am using polar.plot from the {plotrix} library to visualize individual coral colonies, dying, growing, etc through time. These coral colonies, that I visit annually happen to be delineated by a circular plot underwater; hence polar.plot is the best way to visualize my data. (I.e. This is not cyclical data that I am plotting.) I am trying to label individual data points (which correspond to actual coral colonies) with their identifying tag numbers. I have searched and searched and found no polar.plot with text labels on data points.

I tried to coerce the "text" function (code below). But no dice.

   D = runif(29,0,7)         #Distance from center of circular plot (in meters)
   H = runif(29,0,360)      #Compass heading to center of circular plot (in degrees)

   polar.plot(D, H,rp.type = "dots", start = 90, point.col = "red")

   TagID = 200:228          #Labels of individual coral colonies
   text(D,H,TagID)            #lame attempt at coercing the text function


Is it possible to add text labels to data points in polar.plot?

Any assistance will help save an endangered species. (Really!)
Thank you!

Sincerely,
Tali Vardi, PhD Candidate
Center for Marine Biodiversity and Conservation
Scripps Institution of Oceanography
Reply | Threaded
Open this post in threaded view
|

Re: polar.plot text labels for data points

Jim Lemon
On 05/06/2010 03:24 AM, Tali wrote:

>
> Hello All.
>
> I am using polar.plot from the {plotrix} library to visualize individual
> coral colonies, dying, growing, etc through time. These coral colonies, that
> I visit annually happen to be delineated by a circular plot underwater;
> hence polar.plot is the best way to visualize my data. (I.e. This is not
> cyclical data that I am plotting.) I am trying to label individual data
> points (which correspond to actual coral colonies) with their identifying
> tag numbers. I have searched and searched and found no polar.plot with text
> labels on data points.
>
> I tried to coerce the "text" function (code below). But no dice.
>
>     D = runif(29,0,7)         #Distance from center of circular plot (in
> meters)
>     H = runif(29,0,360)      #Compass heading to center of circular plot (in
> degrees)
>
>     polar.plot(D, H,rp.type = "dots", start = 90, point.col = "red")
>
>     TagID = 200:228          #Labels of individual coral colonies
>     text(D,H,TagID)            #lame attempt at coercing the text function
>
>
> Is it possible to add text labels to data points in polar.plot?
>
Hi Tali,
What a great idea!

radial.labels<-function(lengths,radial.pos,units="radians",start=0,clockwise=FALSE,
  labels,adj=NULL,pos=NULL,...) {

  if(units == "clock24") radial.pos<-pi*(450-radial.pos*15)/180
  if(units == "polar") radial.pos<-pi*radial.pos/180
  if(clockwise) radial.pos<--radial.pos
  if(start) radial.pos<-radial.pos+start
  # get the vector of x positions
  xpos<-cos(radial.pos)*lengths
  # get the vector of y positions
  ypos<-sin(radial.pos)*lengths
  text(xpos,ypos,labels,adj=adj,pos=pos,...)
}

You have now immortalized yourself in the plotrix NEWS file. The next
version will include this function. Briefly, pass the same "lengths",
pass your "polar.pos" as "radial.pos" and set units to "polar". The
other arguments are the same as in radial.plot and text.

> Any assistance will help save an endangered species. (Really!)

I hope that the endangered species to be saved is humanity.

Jim

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.