Recent

Author Topic: TaChart ternary plot functionality  (Read 11868 times)

ccrause

  • Hero Member
  • *****
  • Posts: 1094
TaChart ternary plot functionality
« on: May 16, 2012, 12:37:15 pm »
I haven't seen the functionality to create ternary plots (http://en.wikipedia.org/wiki/Ternary_plot, also see figures 1-4 in http://www.sciencedirect.com/science/article/pii/S0021961412000109 for my intended use).  Is it possible using existing functionality or is a new custom graph/series type required?

If so, where should I start if I want to derive something like this using TaChart?

wp

  • Hero Member
  • *****
  • Posts: 13414
Re: TaChart ternary plot functionality
« Reply #1 on: May 16, 2012, 05:08:44 pm »
I think the rectangular coordinate system is the basis of TAChart, and I am quite sure that there no straightforward way to create a ternary plot. However, the same holds for gnuplot, but on http://staff.aist.go.jp/a.noda/programs/ternary/ternary-en.html you can see that this plotting package can be "abused" to draw ternary. Basically, in this reference, the rectangular coordinate axes are hidden ("set noborder; set noxtics; set noytics") and the new triangular coordinate system is drawn by auxiliary lines ("set arrow ..."). Data points undergo a transformation from the ternary to the rectangular coordinate system (see equations at the top of the page). With all the infrastructure available within TAChart, I do not see a reason why TAChart should not be able to draw ternary plots in the same way. You'll have to do some coding though.

Ask

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 687
Re: TaChart ternary plot functionality
« Reply #2 on: May 16, 2012, 09:04:47 pm »
Indeed it is very simple to draw the line itself in "triangular" coordinates.

The question of axes is, however, more complex.
Where should axis marks and axis lines be located?
Do you need interactivity -- zooming, panning, etc?
Should rectangular and triangular axises be allowed on the same diagram?
Are there other useful non-rectangular coordinate systems?

After understanding the above, perhaps I can help in implementing a generic solution.

Meanwhile, you can simulate the ternary plot by using a set of line series with appropriate marks,
as wp described.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12715
  • FPC developer.
Re: TaChart ternary plot functionality
« Reply #3 on: May 16, 2012, 09:25:59 pm »
Indeed it is very simple to draw the line itself in "triangular" coordinates.

The question of axes is, however, more complex.
Where should axis marks and axis lines be located?

Each corner of the triangle is a component (say X,Y and Z)

Every side of the triangle is a binary system of two components X and Y, so that X+Y=1.  IOW at the X corner, Z and Y are zero and X is 1.

Half way between X and Y is the point 0.5 X + 0.5 Y.  The middle point is    X+Y+Z=1 and x=y=z=1/3

Marks are usually not used, except as projections of points where something is "happening" in the graph. (like triple point).

A different name for these kinds of diagrams is "phase diagram", as surfaces in the graph depict the preferred phase of the system at the relevant composition. IIRC they are actually 3D, but the 2D graph is by constant P,T.
« Last Edit: May 17, 2012, 06:25:51 pm by marcov »

ccrause

  • Hero Member
  • *****
  • Posts: 1094
Re: TaChart ternary plot functionality
« Reply #4 on: May 16, 2012, 10:53:15 pm »
Thanks for the replies. I would like to use at least the zoom & pan functionality.  it would probably not make sense to plot rectangular and triangular plots on top of each other i think. At least point and curve series should be available on one graph.
« Last Edit: May 17, 2012, 08:35:25 am by ccrause »

wp

  • Hero Member
  • *****
  • Posts: 13414
Re: TaChart ternary plot functionality
« Reply #5 on: May 17, 2012, 11:11:46 am »
Since I have always been fascinated by ternary plots I am posting a unit which allows quick-and-dirty drawing of ternary diagrams with TAChart. It roughly follows the approach referred to in the second posting above. See the header of the unit "ternary.pas" for instructions.

I know this is not perfect - for example, you cannot zoom and pan, but it could serve as a temporary solution until a solid integration into TAChart is available.

@ask: If you consider implementing non-rectangular axes to TAChart the solution should be general enough to allow also polar diagrams (http://devnet.logixml.com/rdPage.aspx?q=devnet%2frdPage.aspx&rdReport=Article&dnDocID=1083&dView=1&IdeDisplayStatus=Collapsed) or spider diagrams (http://en.wikipedia.org/wiki/Radar_chart)

Ask

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 687
Re: TaChart ternary plot functionality
« Reply #6 on: May 17, 2012, 05:40:30 pm »
Quote
If you consider implementing non-rectangular axes to TAChart the solution should be general enough to allow also polar diagrams
Yes. This is why I inquired about other similar plot types.
By the way, a simple form of polar charts is already supported (http://wiki.freepascal.org/TAChart_documentation#Polar_series).

ccrause

  • Hero Member
  • *****
  • Posts: 1094
Re: TaChart ternary plot functionality
« Reply #7 on: May 17, 2012, 10:21:22 pm »
Since I have always been fascinated by ternary plots I am posting a unit which allows quick-and-dirty drawing of ternary diagrams with TAChart. It roughly follows the approach referred to in the second posting above. See the header of the unit "ternary.pas" for instructions.
...

That was quick!  And it looks decent too.  I have tried to do something similar but starting from a TPaintBox.  It quickly became apparent that I was trying to re-invent the Chart structure. I decided to stop once I managed to draw a triangular graph with grid lines and the ability to plot a single series.  The one feature I like is the ability to maintain an equilateral triangular plot surface when resizing.  Anyway my very limited functionality attempt is attached.

wp

  • Hero Member
  • *****
  • Posts: 13414
Re: TaChart ternary plot functionality
« Reply #8 on: May 17, 2012, 11:11:25 pm »
Set the chart property Proportional to true, and the triangle will remain equilateral when resizing the window.

ccrause

  • Hero Member
  • *****
  • Posts: 1094
Re: TaChart ternary plot functionality
« Reply #9 on: May 18, 2012, 08:52:03 am »
Thanks wp, Proportional := true fixed the display nicely.  I hope something like this eventually ends up as part of TAChart.

 

TinyPortal © 2005-2018