[R] centroid of diamond

Jim Lemon jim at bitwrit.com.au
Fri Mar 14 09:22:44 CET 2014


On 03/14/2014 07:05 PM, al Vel wrote:
> Hi,
>
> I was very clear in the mail that i want to create a four edged
> Barycentric diagram like Ternary plot (like the rhombus in the piper
> diagram (http://en.wikipedia.org/wiki/Piper_diagram)).  The idea is to
> graphically depicts the ratios of the four variables as positions in an
> rhombus/diamond shape. The more the value, then the point will be
> towards that edge. In a four edged plot, the proportions of the four
> variables /a/, /b/, c, d must sum to some constant, /K/. Usually, this
> constant is represented as 1.
> The code is simple for 3-edged ternary plot:
>
>  >grid.polygon(c(0, 0.5, 1), c(0, sqrt(3)/2, 0), gp = gpar(col = "black"))
>  >xp <- proportionvalueofB + proportionvalueofC / 2
>  >yp <- proportionvalueofC * sqrt(3)/2
>  > grid.points(xp, yp, pch = 1, size=size, default.units = "snpc")
>
> (example if a=10,b=20,c=40; then proportionvalueofB=20/70)
>
> The second two line in the above code converts the proportion value into
> a cartesian co-oridinate to plot. This is for the triangle. The question
> is how do i convert the proportions of 4 values into a cartesian
> co-ordinate in a rhombus or a diamond.
>
>
> Best regards,
> Alaguraj.V
>
Hi Alaguraj,
Okay, the A, B, C, and D represent distances along the sides of a 
rhombus. The important thing is that you have answered your own 
question. The Wikipedia page above has the matrix transformation to 
solve your problem. Also have a look at this site:

http://water.usgs.gov/nrp/gwsoftware/GW_Chart/GW_Chart.html

where there is free software to draw Piper diagrams. Unfortunately, it 
is written in Pascal so that I can't easily translate it into R. There 
is an R package "hydrogeo" that may have a Piper diagram function in it. 
If you manage to sort this out, please let me know as I had a Piper 
diagram function that was contributed to the plotrix package but didn't 
work.

Jim




More information about the R-help mailing list