ms609 / Ternary

Create ternary plots in R

Home Page:https://ms609.github.io/Ternary/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Suggestion: Point labels outside of plot with leaders

dan-montocc opened this issue · comments

Hi Martin,
I was wondering if it is possible to add labels to ternary plot points but with leaders so the labels are outside of the plot (I have attached an example image of what I mean).

image

This can be done "manually", with a little work. You'll need a few functions:

  • TernaryToXY() will give the Cartesian coordinates of the points you wish to annotate
  • TernaryXRange() will give the X coordinates of the edges of the plot (likewise for Y)

You can then use the standard line() and text() to add the text where it is desired.

Hope that helps – let me know if a more detailed walk-through would be helpful.

  • Martin

Hi Martin,
I can't seem to get the correct object type for TernaryToXY() to run with my data. Would you be able to provide some example code when you have the chance? I have attached my data if it helps to have something to work with. The a-axis is Comp, b-axis is Stress, and c-axis is Rud in the listed variables. I would like to be able to label using the Number or ID variable if possible.
Thank you once again for your help and awesome package!

PierceGBSpeciesClassification.csv

Hi @dan-montocc your figure looks great. Can you please point me in the direction of the functions to generate ticks against points and the labels color separated? Also, is there an ggrepel equivalent for keeping the labels separate? Many thanks.

I should hopefully have time to assemble a worked example next week... watch this space!

I suspect that the missing instruction was that you need to t() the data frame before passing it to TernaryToXY(). I can't remember why this function needs the data in this orientation – perhaps it was a naive design decision by me...

You can now find a full worked example at
https://ms609.github.io/Ternary/dev/articles/annotations.html