Re: Ternary Plot in IDL? [message #83813] |
Tue, 09 April 2013 06:27 |
JP
Messages: 55 Registered: April 2008
|
Member |
|
|
Oh, cool, will have a look.
I had been trying myself, after finding that it's really a simple reprojection of a 2d space.
Came up with the very rudimentary procedure below (before reading your reply). Doesnt have much functionality but it works).
JP
pro TernaryPlot, x, y, z, $
_EXTRA=extra
; write warnings for x, y not being within 0-1 and adding to more than 1
; first check if z exists or not
n_x = n_elements(x)
n_y = n_elements(y)
n_z = n_elements(z)
if n_z eq 0 then begin
print, 'z not present, assumed to be = 1-x-y'
z=1-x-y
n_z = n_elements(z)
endif
; check if x, y, z, all same # of elements
if (n_x ne n_y) or (n_x ne n_z) or (n_x ne n_z) then $
Message, 'x, y, z must have same number of elements'
; check if all sum to one
tot = x+y+z
if total(tot gt 1) ge 1 then $
print, 'warning: at least one element adds to >1 '
if total(tot lt 1) ge 1 then $
print, 'warning: at least one element adds to <1 '
x_new = y + z/2
y_new = SQRT(3)/2*z
vertices_x= [0.0, 0.5, 1, 0]
vertices_y= [0.0, SQRT(3)/2, 0, 0]
cgPlot, x_new, y_new, xRange=[0,1], yRange=[0, SQRT(3)/2], yStyle=1, _EXTRA=extra
cgPlot, vertices_x, vertices_y, psym=-3, /overplot
end
On Tuesday, 9 April 2013 21:56:15 UTC+10, David Fanning wrote:
> David Fanning writes:
>
>
>
>> Fernando Santoro has a Ternary Diagram program, written in function
>
>> graphics, in the IDL code library on the ExelisVis web page. He also
>
>> wrote the Taylor Diagram code that I cribbed for cgTaylorDiagram. It
>
>> took me most of a morning to do it. I won't take you too much longer, I
>
>> don't think, to do the same thing for the Ternary Diagram. :-)
>
>
>
> Just looking at that code, not only is it going to take you just a
>
> couple of hours to convert to Coyote Graphics, but it is also going to
>
> be easy to make improvements! For example, I would start by centering
>
> the diagram in the window, adding keywords to allow for different
>
> symbols of different sizes, etc. It is pretty bare bones in its current
>
> configuration.
>
>
>
> Cheers,
>
>
>
> David
>
>
>
>
>
> --
>
> David Fanning, Ph.D.
>
> Fanning Software Consulting, Inc.
>
> Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
>
> Sepore ma de ni thue. ("Perhaps thou speakest truth.")
|
|
|
Re: Ternary Plot in IDL? [message #83815 is a reply to message #83813] |
Tue, 09 April 2013 04:56  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
David Fanning writes:
> Fernando Santoro has a Ternary Diagram program, written in function
> graphics, in the IDL code library on the ExelisVis web page. He also
> wrote the Taylor Diagram code that I cribbed for cgTaylorDiagram. It
> took me most of a morning to do it. I won't take you too much longer, I
> don't think, to do the same thing for the Ternary Diagram. :-)
Just looking at that code, not only is it going to take you just a
couple of hours to convert to Coyote Graphics, but it is also going to
be easy to make improvements! For example, I would start by centering
the diagram in the window, adding keywords to allow for different
symbols of different sizes, etc. It is pretty bare bones in its current
configuration.
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
|
|
|
Re: Ternary Plot in IDL? [message #83816 is a reply to message #83815] |
Tue, 09 April 2013 04:41  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
JP writes:
> Googled that in the group and it doesn't seem to be anything done for that yet althought ppl have asked about it every now and then.
>
> I am after a ternary plot http://en.wikipedia.org/wiki/Ternary_plot
> Was told that R has a function for it: http://rss.acs.unt.edu/Rdoc/library/vcd/html/ternaryplot.htm l
>
> Wouldn't it be great if there was something like it in IDL?
>
> maybe a cgTernaryPlot procedure? ;) ;)
Yeah, that would be great. :-)
Fernando Santoro has a Ternary Diagram program, written in function
graphics, in the IDL code library on the ExelisVis web page. He also
wrote the Taylor Diagram code that I cribbed for cgTaylorDiagram. It
took me most of a morning to do it. I won't take you too much longer, I
don't think, to do the same thing for the Ternary Diagram. :-)
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
|
|
|