Site icon R-bloggers

New Geometry – Tline, Lline & Rline

[This article was first published on ggtern: ternary diagrams in R, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

The latest version of ggtern, 1.0.1.0, has several bug-fixes and improvements. One worth mentioning, is the creation of some new geometries to assist in the plotting of constant value lines, analogous to hline and vline in ggplot2.

For Lines of constant T value:

< !--INFOLINKS_OFF-->

ggtern() + geom_Tline(Tintercept = 0.5, size = 2, color = "red")

< !--INFOLINKS_ON-->

For Lines of constant L value:

< !--INFOLINKS_OFF-->

ggtern() + geom_Lline(Lintercept = 0.5, size = 2, color = "green")

< !--INFOLINKS_ON-->

For Lines of constant R value:

< !--INFOLINKS_OFF-->

ggtern() + geom_Rline(Rintercept = 0.5, size = 2, color = "blue")

< !--INFOLINKS_ON-->

Or using some convenience functions that have been included:

< !--INFOLINKS_OFF-->

ggtern() + 
  Tline(0.5, color = "red", size = 2) + 
  Lline(0.5, color = "green",size = 2) + 
  Rline(0.5, color = "blue", size = 2)

< !--INFOLINKS_ON-->

Of course, just like hline and vline in ggplot2, multiple values can be provided

< !--INFOLINKS_OFF-->

ggtern() + Tline(seq(0.1, 0.9, by = 0.1), color = "red", size = 2)

< !--INFOLINKS_ON-->

And they can be used from aesthetic mappings:

< !--INFOLINKS_OFF-->

df <- data.frame(x = runif(10), y = runif(10), z = runif(10))
df <- df/apply(df, 1, sum)
ggtern() + geom_Lline(data = df, aes(Lintercept = y), color = "green", size = 2)

< !--INFOLINKS_ON-->

The post New Geometry – Tline, Lline & Rline appeared first on ggtern: ternary diagrams in R.

To leave a comment for the author, please follow the link and comment on their blog: ggtern: ternary diagrams in R.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.