Wednesday, 18 April 2018

How to use GCDkit in a batch mode II

In one of the earlier blogs, Jeff has presented my exercise showing effective use of batch mode borrowed from our joint workshop at University of Catania.  

Here I would like to carry on and show the new capabilities of GCDkit to use multiple datasets and to overplot them on a single diagram (or plate thereof).

Binary plot

# Loading and storing the 1st dataset

Loading and storing the 2nd dataset

Switching back to the atacazo dataset
# Overplotting classification diagram


# Overplotting on spiderplot

# Atacazo as grey field

A plate (Harker plots)

# blatna dataset
plateXLim(c(53,70)) # Common x axis scaling
plate0YLim() # All y axes start from 0


# Overplot sazava on top of it

# Getting rid of the datasets other than the current (blatna)

User-defined diagrams in GCDkit 5.0

Due to a popular demand, the new version of our program comes with a straightforward possibility of adding (Figaro-compatible) templates for both stand-alone binary/ternary diagrams and plates. If done correctly, they integrate seamlessly into the GCDkit system, namely into the menu 'Plots|User defined...' .

There are still some limitations, though. So far, the user-defined diagrams cannot be used for classification purposes (and hence for defining subsets, groups…).  We cannot offer language versions other than English, either.


All *.r or *.R files stored in the directory Diagrams/User , except for those whose name starts with underscore ("_"), are sourced every time the menu item 'Plots|User defined...' is invoked. Hence the list of available diagrams is always built on fly, using the function .userlist().

The ordering information and name under which it appears in the menu are integral parts of the template. For stand-alone, single Figaro plots, the crucial information is:
  • Name of function defining a diagram
  • Name of the plot: sheet$demo$template$GCDkit$
  • Sequence number of the plot in the menu: sheet$demo$template$GCDkit$plot.position

For a plate of Figaro templates:
  • Name of function defining a plate
  • Name of the whole plate: plate$
  • Sequence number of the plot in the menu: plate$plot.position 

In both cases, the file should define a single function of a name identical to (the root of) the filename.
 'Sequence number' above is any positive real number (i.e., it does not have to be an integer).


The HTML documentation is linked to the help system automatically. However, this is only done when the *.htm file, named exactly like the function, resides in Diagrams/User/doc subdirectory.

An example

Here is an example of the Al2O3/SiO2 vs MgO/SiO2 binary plot of Paulick et al. (2006). This is done using the function Paulick provided in the file Paulick.r  of  the current GCDkit distribution.

#                  Al2O3/SiO2 vs MgO/SiO2 binary plot               #
#                   Fig. 3 in Paulick et al. (2006)                 #
#  Paulick, H., Bach, W., Godard, M., De Hoog, J.C.M., Suhr, G.,    #
#  Harvey, J., 2006. Geochemistry of abyssal peridotites (Mid-      #
#  Atlantic Ridge, 15o20'N, ODP Leg 209): implications for fluid/   #
#  rock interaction in slow spreading environments. Chemical Geo-   #
#  logy, 234: 179-210.                                              #

col="darkgray", lwd=10),
plot.position=12,"Al2O3/SiO2 - MgO/SiO2 (Paulick et al. 2006)"

text="Terrestrial Array\n(melting trend)",

if(getOption("gcd.plot.text")) temp<-c(temp,temp2) # Text on?

main=annotate("Al2O3/SiO2 - MgO/SiO2 plot
  (Paulick et al. 2006)"

Saturday, 14 April 2018

Version 5.0 has been just released!

On March 28, 2018 has been released a new version of GCDkit 5.0. It was developed in R 3.4.3 and code-named El Chupacabra. The most important changes are summarised below.

Towards a platform-independent version
  • It is well-known that the GCDkit has been originally designed as a Windows-only package. From the current version it is possible to install  and run it also on operation systems other than Windows,  most notably Linux or Mac OSX.  
  • So far, this concerns command-line/batch mode only. 
  • The platform-independent graphical user interface (menus, dialogue boxes...) written in Tcl/Tk language  is ready and just being tested. If you are feeling unadventurous, and work on Linux and/or Mac, please do get in touch and you can become one of the beta testers. 

New Windows installer
  • As we hope, we have fixed the long-standing problems with the installation of GCDkit on Windows 10, and people without administrative rights.
  • The new GUI installer, based on the Tcl/Tk  language,  is started by simply dragging the file @INSTALL.r from the temporary installation directory onto the R Console window. 
  • his file can be also located manually and loaded using the  File|Source R code...'  menu. See the download page for more details. 
  • Please note that this installer relies on a live Internet connection to download the missing packages required by the GCDkit. 

User-defined templates
  • User-defined templates for stand-alone Figaro plots or their plates. They can be uploaded into the  directory Diagrams/User and then employed for standard plotting (i.e. not classification)  purposes. This mechanism allows easy and fully automatic expansion of the plotting capabilities  of the GCDkit system. For further info, see the file @README.txt in the directory in question.
  • There are five examples of user-defined templates provided: three binary plots for discrimination of lavas from destructive plate boundaries (Pearce 1982), ternary plot for classification of A-type granites (Grebennikov 2014) and binary plot of Paulick et al. (2006) to portray the mantle peridotite fertility.  

Overplotting two or more datasets on a single diagram (or plate)
  • Functions allowing overplotting new datapoints onto standard single binary plots, ternary plots,
    spiderplots or multiple plots, including the diagram templates (overplotDataset, underplotDataset) linked to the menu system. 
  • In addition, there are functions figOverplot and figOverplotDiagram but these are meant mostly for internal use. 
  • For plotting serves a reference dataset, either real-world data (say compiled from literature) or a numeric  matrix spanning, for instance, from petrogenetic modelling.
  • See the example of overplotting the atacazo over sazava dataset on De la Roche et al. (1980) plot.
  • Very attractive feature should be the new possibility of obtaining dataset by online search of the database. The search can be performed directly from the menu GCDkit|Online search  It invokes a graphical front-end, written By Oscar Laurent (ETH, Zurich) that allows to enter the desired search criteria. On Windows, it also includes a primitive, and still rather slow, possibility of selecting a polygon of interest from a map of the World. 

Further new features/important changes
  • New plugin 'disclosure' for log-transformation of compositional data.
  • New geotectonic/general purpose diagrams
    • La/Yb vs. Nb/La and La/Yb vs. Th/Nb of Hollocher et al. (2012)
    • La/10-Y/15-Nb/8 of Cabanis and Lecolle (1989)
    • Zr/Y-Th/Yb of Ross and Bedard (2009)
    • YbN vs. LaN/YbN of Martin (1986) to distinguish adakites and TTGs
    • F-M-W diagram (Ohta and Arai 2007) for chemical weathering of igneous rocks
  • calcAnomaly, a function for calculating a magnitude of any anomaly on any spiderplot, based on concentrations of selected neighbouring (not necessarily adjacent) elements.
  • Spanish translation of the classification plots (courtesy of Tomas Grijalva,  Geology Department of UNAM, Mexico).
  • New zircon saturation model of Boehnke et al. (2013).
  • New training dataset giving the whole-rock major- and trace-element contents,   together with Sr and Nd isotopic compositions of lavas from two volcanic complexes in Ecuador: the Atacazo and the Ninahuilca (Hidalgo 2006; Hidalgo et al. 2008).   This dataset, kindly provided by Silvana Hidalgo, is used in a worked example (chapter 25) of Janousek et al.’s book (2016).
  • Another new training dataset from the Central Bohemian Plutonic Complex, Czech Republic  (Janousek et al. 2000, 2010). It could be, together with already present, used to test dataset switching etc.
  • New function figFixLim() extends the scales of both axes of a binary plot automatically  if necessary to accommodate all the data points.
  • new training dataset from the Central Bohemian Plutonic Complex, Czech Republic (Janousek et al. 2000, 2010). It could be, together with already present, used to test   dataset switching etc.
  •  New function figFixLim()extends the scales of both axes of a binary plot automatically  if necessary to accommodate all the data points.
  • New normalization scheme of Anders and Grevesse (1989) for chondrite-normalized REE spiderplots.
  • Better behaviour of many functions in batch mode (in RTerm, Jupyter, on Linux/Mac etc.)......

  • We trust that you will find this new release useful and reasonably stable.

    Good luck, Vojtech

Tuesday, 23 May 2017

Batch / Console mode

One of the nice features in the recent versions of GCkit is that it can be ran without any graphical user interface, just by typing commands in the console.

What good is it, will you say ? Well:
  • It saves time. After a while it gets a bit annoying to have to go to "plot", "binary", select X variable, select Y variable "ok", "ok"... Isn't it easier, and faster, to just type binary("SiO2","Rb/Sr") ? I think so.
  • It is reproducible. You can copy a string of commands to a file, and re-run the file every time you need it, perhaps because you've updated the dataset, or you're doing the same thing with all of your data anyway.
  • Since it does not rely on the GUI, it is platform-independent (ha-ha !).  So this allows to use GCDkit on platforms other than windows.

All the commands that are found in the menus can be used from the command line (and, in fact, even more or at least with more flexibility). So you may, for instance, run the following scripts (borrowed from the latest workshop in Catania).
In all examples, you may either copy the commands to a text file, that you save as "something.r", and then drag and drop the r-file to your console; or type each command in succession into the console.
Also, we assume in each example that you have the relevant data files, stored in a directory that happens to be, in this case, C:\\Users\\admin\\Documents\\R code\\.The datafiles are from the book.

Example 1 (loading and grouping data; simple calculations)

setwd("C:\\Users\\admin\\Documents\\R code\\")

     Sa-1      Sa-2      Sa-3      Sa-4      Sa-7     SaD-1     Gbs-1    Gbs-20     Gbs-2     Gbs-3
0.8355344 0.7618697 0.8078703 0.7193632 0.9617544 0.8418038 0.4370269 0.5549208 0.7506752 0.8598510
     Po-1      Po-3      Po-4      Po-5
0.9716144 1.0248678 1.0129914 1.169989

spider(WR,"Boynton",plot=FALSE) # Calculation only

Example 2 (simple diagrams)

setwd("C:\\Users\\admin\\Documents\\R code\\")

# Binary plot

binary(x="SiO2",y="Y",ymin=0,ymax=50,main="My Binary plot")


# A single classification diagram, zoom in





# Harker plot (a simple plate)






Example 3 (Custom plates)

setwd("C:\\Users\\admin\\Documents\\R code\\")

# Custom plate


plotDiagram("Meschede",F,F,main=" ")

plateExtract("Wood",3,main=" ")

plotDiagram("PearceNbThYb",F,F,main=" ")

plotDiagram("PearceNbTiYb",F,F,main=" ")




(this example involves still a lot of clicking in dialogs, so it is not too likely to work in non-windows environments)

Example 4 (spiderplots)

setwd("C:\\Users\\admin\\Documents\\R code\\")


# REE spider



# NMORB Sun and McDonough