New Geometry – Tline, Lline & Rline

December 16, 2013
By

(This article was first published on ggtern: ternary diagrams in R, and kindly contributed to R-bloggers)

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:

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

plot of chunk unnamed-chunk-2

For Lines of constant L value:

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

plot of chunk unnamed-chunk-3

For Lines of constant R value:

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

plot of chunk unnamed-chunk-4

Or using some convenience functions that have been included:

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

plot of chunk unnamed-chunk-5

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

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

plot of chunk unnamed-chunk-6

And they can be used from aesthetic mappings:

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)

plot of chunk unnamed-chunk-7

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 on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...



If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.

Sponsors

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)