Ternary diagrams are common in chemistry and geosciences to display the relationship of three variables. Here is an easy step-by-step guide on how to plot a ternary diagram in Excel.
Although ternary diagrams or charts are not standard in Microsoft® Excel, there are, however, templates and Excel add-ons available to download from the internet. Nevertheless, it might be advantageous to build your own template as it gives you more freedom to display data and which additional parts (ticks, lines, values, etc.) you want to display. Find a step-by-step guide on how to generate a ternary chart in Excel that you can customize towards your requirements.
Due to the use of larger-scale images in this article, some images may be too small when displayed on mobile/cell phones; a tablet, laptop, or PC screen is recommended.
How does a ternary diagram work?
A ternary or triangular diagram (chart/plot/graph) is a graphical way to display the relationship between three variables or components.
To display three variables in a ternary graph, their values must be normalized to a constant, usually either 1 or 100%.
The advantage of ternary plots is that three variables can be displayed in a two-dimensional way. The disadvantages are that these variables are normalized to a constant (1 or 100%) and therefore have different values than initially, which are also not independent of each other.
I assume the data will be normalized to 100% in the following descriptions, but the theory is the same for normalization to 1%. By the way, all ternary plots here are generated in the way I am going to show you.
I follow clockwise labeling of the ternary diagram, i.e., A on top, B on the right (bottom), and C on the left (bottom apices.
Before we start, just a quick explanation of how to read a ternary diagram helping us understand what we need to achieve.
How to read a ternary diagram?
A ternary diagram consists of an equilateral triangle of which the apices represent 100% and the opposite base/side 0% of each variable.
Let’s assume you have three variables, A = 42.5%, B = 25.5%, and C = 17%. This sums up to 85%. Those values change to A = 50%, B = 30%, and C = 20% when normalized to 100% (see math/formula below).
Plotted into a ternary graph, it looks like this (Figure 1):
Let’s start with component A: the apex A (top) represents 100%, and the base opposite the apex equals 0%. So starting from the base towards the top apex, we can determine the value of component A (Figure 2), here 50%.
Now, we do the same with component B (Figure 3) starting from the base (0%) opposite apex B on the lower right (100%), which gives us the value of 30%.
And finally, component C is determining from the right side/base (0%) towards apex C on the bottom left side leading to a value of 20% (Figure 3).
Building a ternary diagram in Excel
Microsoft® Excel displays two axes only. The trick is thus to convert/project our ternary system into a binary system. This sounds more complicated than it is.
STEP 1: Preparing the spreadsheet
In the example I use here, I am using 3 columns for the original (non-normalized) geochemical data i.e., 3 components. Then another 3 columns for the normalized values, and a fourth column for the sum of the previous three as a check option. This is followed by two columns, which will show the XY coordinates of the binary plot of the ternary diagram.
In Figure 4, you can see the basic outline of the spreadsheet.
Normalizing the original data
Like mentioned before, the data we want to display in a ternary diagram need to be normalized to either 1 or 100%; here we are using the 100% approach.
We start with determining the coordinates for our ternary diagram apecis, i.e., the outline of it (triangle); i.e., A = 100%, B = 100%, and C = 100%.
In the spreadsheet, we type 100 into cell B4, 0 into cell C4, and 0 into cell D4 (meaning 100% A = A-apex). For the B-apex, we type 0 into cell B5, 100 into cell C5, and 0 into cell D5, and finally for the C-apex 0 into cells B6 and C6, and 100 into cell D6 (see Figure 5).
Next, we set up the cells and columns to normalize the initial values in columns F, G, and H.
To normalize component A to 100% in relation to the other components use the following formula:
Basics to know …
Normalization to 100%
Anorm = 100*A/(A+B+C). Accordingly: Bnorm = 100*B/(A+B+C) and Cnorm = 100*C/(A+B+C).
According to this, type the following into cell F4 to normalize A’ to 100%: =100*B4/(B4+C4+D4), see the Excel Formula Bar in Figure 5. Cell G5 is =100*C4/(B4+C4+D4) and cell H5 gets =100*D4/(B4+C4+D4) to normalize components B’ and C’ respectively.
I put the sum of columns F, G, and H into column I (i.e., =SUM(F4:H4) or =F4+G4+H4), for double-chicking everything works fine. Then drag the content of cells F4 to I4 down. Your spreadsheet should have the numbers in it like under the blue and green marked cells in Figure 5.
You may argue that the initial data (A’, B’, and C’) are already summing up (are normalized) to 100%. In this case, that is right. You can test, however, if your cells are set up correctly, by replacing the 100 entries with random numbers, the normalized values should stay the same. Double-check by additionally replacing a 0 in the non-normalized data with a random number too. The normalized value should change accordingly, but the sum should still be 100 (Figure 6).
Calculating the X and Y coordinates
The next step is to calculate the X and Y coordinates so we can plot the triangular (ternary diagram).
I set up columns K and L for the X and Y coordinates (Figures 4 and 5).
The conversion into X and Y coordinates is straightforward:
The Y-axis value
The Y-axis equals the height of component A (Figure 7), thus Y = A.
The X-axis value
The X-axis equals half the height of component A plus component B, thus X = 0.5xA + B.
The XY coordinates of the triangle
Putting this into action, we know the ABC coordinates of the triangular/ternary, and applying the conversion as outlined above, we get the XY coordinates as shown in Figure 5, columns K and L.
To close the triangle shape, we need to add one point twice, but in order (Figure 8)
Copy the values of the calculated XY coordinates to a separate place in the spreadsheet so they are out of the way (e.g., to columns AA and AB and label them accordingly, Figure 8).
We are now ready to plot the outline of the triangle, which will become our ternary diagram.
STEP 2: Plotting the ternary into a binary diagram
Insert a Scatter Chart
Insert a Scatter Chart (XY diagram), e.g., ‘Scatter with Straight Lines’ (Figure 9) using the XY coordinates for the triangle from columns AA and AB. To make it into an equilateral triangle resize the chart area accordingly; for example 10 columns wide and 30 rows high, as in Figure 10. (You can check by drawing a triangle (Insert > Shapes > Triangle); hold the Shift key, which will make the triangle equilateral, while drawing the triangle over the diagram.)
Adjust the XY axes scales
Excel will automatically scale the X and Y axis from 0 to 120; we need to change both axes to 0 to 100 (see Figure 11).
Adding labels to the apices
Next, we need some space for the apices labels: click into the Plot Area (not the Chart Area) then resize by holding the Shift key (this ensures an equal scaling) and use the mouse cursor on one of the corner pick-points. Then recentre the Plot Area in the Chart Area.
Insert a Text Box (Insert > Shapes > Text Box) on top of the apex A, and instead of text type in (or use the mouse and click into the cell) the cell location. In our example the text box for the top apex “=$F$3”, right bottom “=$G$3”, and left bottom “=$H$3” (displaying A (centered), B (aligned right), and C (aligned left), respectively); Figure 12. In this way, if you change the entry of the labels in cells F3 (A), G3 (B), and H3 (C), it will automatically show in the diagram.
Cleaning up the chart
Delete the vertical and horizontal gridlines.
Delete the Y-axis.
Change the line color of the triangle (if you like) and adjust the line thickness, i.e., same for triangle and X-axis.
Adding tick marks and labels to the axes
Adding tick marks
We start with the X-axis; like in an XY chart, add tick marks to the X-axis (recommended type: Cross rather in Inside or Outside; see below).
Add two new data tables with coordinates and labels, as in Figure 13, to your Excel spreadsheet, e.g., close to the coordinates for the triangle, and somewhat out of the way.
Add the XY coordinates as new data series to the diagram (Figure 14).
The data points will likely be displayed as a line. Change their appearance from a ‘line’ (Format Data Series > Fill and Line > Line) (Figure 15) to ‘long dash’ symbols (Figure 16); the long dash will mimic the Cross type of tick marks of the X-axis set up earlier. Change the color accordingly to those of the X-axis.
Do this for the axis between A and B, and between A and C.
Adding labels to the tick marks
Use the Add Chart Element > Add Labels (Chart Design tab) to add Data Labels to the A to B axis aligned to the right (Figure 17), then add Data Labels aligned left to the C to A axes.
By default, Excel will use the Y Value as Data Label. You can change this, if you want, for instance, the labels in the opposite direction, by changing the Label Option (Format Data Labels) to Value From Cells, and then use the Select Range button to select the cells (here the labels we wrote earlier).
Adding gridlines
In the final step, we add gridlines to the graph. We need to add another table with XY coordinates. You can calculate the coordinates with our template, but I provide the coordinate in a separate table [follow this link]. I copied the data, again somewhat out of the way, into columns AA and AB.
Add another data series to the graph with the coordinates for the gridlines. In our example, the data are displayed as dotted lines in grey.
All done …
… a ternary diagram in Excel
So, that’s it, the ternary diagram is built and ready to get some data in.
Step 3: Add your data
So, the spreadsheet and chart are set up and finally ready to display your data.
Add the raw (non-normalized) data into columns B, C, and D (starting with row 4). You may have to extend the range of columns F to I, K, and L to calculate all parameters (Figure 20).
Then add the new data points to the triangular diagram (e.g., right mouse click into chart > Select Data > Add New Data Series > Edit Series, and select the data in columns K and L), just as you usually do.
Note: Have you noticed that I added labels for the three apices into cells F3, G3, and H3, which then are displayed at the apices of the ternary diagram (Figure 20); – remember how we set this up in step 2.3 (Figure 12)
How about displaying data point values?
It may be useful to display the actual ternary values next to the data points in the diagram. If you (right mouse click on data points > Add Data Labels), Excel will display by default the Y-Value, i.e., the values from column L. Double-click in the data labels and you can add the X-Value and number of digits to be displayed. This may be adequate for your purpose, e.g., identifying a certain data point in the table.
However, maybe you want to display the actual ternary coordinates of the data points. Here is how to do that:
Setting up the ternary coordinates display
To display the actual ternary coordinates (A, B, C) we need to do some preparational work.
In the example below (Figure 21), I extended column Y between the chart and the coordinates for the triangle, tick marks, for the data labels we want to display. You can, however, put them wherever you see it fits best for your purposes.
I called the heading ‘Data Labels’; note the heading is aligned with those from the data, i.e., row in 3 (Figure 22).
In row 4 (below that header), type in the following formula:
=CONCAT(TEXT(F4,”0.0″),”, “,TEXT(G4,”0.0″),”, “,TEXT(H4,”0.0”))
‘CONCAT’ is the Excel function combining text from several cells, ranges, and or strings (note: in older Excel versions the function is called ‘CONCATENATE’). The ‘TEXT’ function converts a numeric value to text, which enables us to give it a certain format. This format is expressed by the string “0.0”, which restricts the number format to one digit behind the comma (“0” would mean no digits, and “0.00” two digits behind the comma respectively). F4, G4, and H4 are the cells we want to combine; see Figure 22 for a visual explanation.
Help me to …
Make it Better
I am sure there may be a different, possibly easier way than the CONCAT / CONCATENATE function, to do that, but that’s out of my Excel expertise; – drop me a note in the comment box below, if you know a different way.
Coming back to displaying the data point labels in the chart. Like before, or your preferred way, add Data Labels to the data points and open the Format Data Labels dialog (e.g., right mouse click on data points > Add Data Labels, or if you have already data labels shown, double click on the labels), untick Y Value and/or X value and tick Value From Cells. Then use the Select Range button to select the cells in column Y; similar to Figure 18).
That’s it. You should have a ternary diagram plotted in Excel that looks similar to the one in Figure 23.
Related article
The geochemical differentiation diagram for sedimentary rocks after Mason (1966)