Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion: Point labels outside of plot with leaders #64

Closed
dan-montocc opened this issue Jan 13, 2023 · 6 comments · Fixed by #65
Closed

Suggestion: Point labels outside of plot with leaders #64

dan-montocc opened this issue Jan 13, 2023 · 6 comments · Fixed by #65

Comments

@dan-montocc
Copy link

dan-montocc commented Jan 13, 2023

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

@ms609
Copy link
Owner

ms609 commented Jan 17, 2023

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

@dan-montocc
Copy link
Author

dan-montocc commented Jan 17, 2023 via email

@dan-montocc
Copy link
Author

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

@archgen
Copy link

archgen commented Jan 19, 2023

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.

@ms609
Copy link
Owner

ms609 commented Jan 19, 2023

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

@ms609 ms609 linked a pull request Jan 25, 2023 that will close this issue
@ms609 ms609 closed this as completed in #65 Jan 25, 2023
@ms609
Copy link
Owner

ms609 commented Jan 25, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants