December 12, 2013

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

Sean Mulcahy made an example of plotting Elkin and Grove's 1990 Feldspar Data. Here is an equivalent plot in three variables:

  1. Phase (Shape)
  2. Temperature (Color Gradient), and;
  3. Pressure (Size)

plot of chunk unnamed-chunk-2

Code to Produce the Above…

# Load data

# Sort it by decreasing pressure 
# (so small grobs sit on top of large grobs
Feldspar <- Feldspar[with(Feldspar, order(-P.Gpa)), ]

# Build and Render the Plot
ggtern(data = Feldspar, aes(x = An, y = Ab, z = Or)) + 
    #the layer
    geom_point(aes(fill = T.C, 
                   size = P.Gpa, 
                   shape = Feldspar)) + 
    scale_shape_manual(values = c(21, 24)) + 
    scale_size_continuous(range = c(2.5, 7.5)) + 
    scale_fill_gradient(low = "green", high = "red") + 

    #theme tweaks
    theme_tern_bw()  + 
    theme(legend.position      = c(0, 1), 
          legend.justification = c(0, 1), 
          legend.box.just      = "left") + 
    #tweak guides
    guides(shape= guide_legend(order   =1,
           size = guide_legend(order   =2),
           fill = guide_colourbar(order=3)) +

    #labels and title
    labs(size = "Pressure/GPa", 
         fill = "Temperature/C") + 
    ggtitle("Feldspar - Elkins and Grove 1990")

The post Feldspar 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.


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)