Wednesday, 18 April 2018

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.

Principle

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$plot.name
  • 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$plot.name
  • 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).

Documentation

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.                                              #
##################################################################### 
Paulick<-function(){
    x.data<<-WR[,"Al2O3"]/WR[,"SiO2"]
    y.data<<-WR[,"MgO"]/WR[,"SiO2"]

    temp<-list(
lines1=list("lines",x=c(0,0.1),y=c(1.1,0.842),
col="darkgray", lwd=10),
GCDkit=list(
"NULL",
plot.type="binary",
plot.position=12,
plot.name="Al2O3/SiO2 - MgO/SiO2 (Paulick et al. 2006)"
)
)

temp2<-list(
text1=list("text",x=0.095,y=1.008,
text="Terrestrial Array\n(melting trend)",
col="black",adj=c(1,0.5),srt=-10),
            text2=list("text",x=0.002,y=1.15,text="Depleted",
col=plt.col[2],adj=c(0,0.5)),
text3=list("text",x=0.099,y=0.83,text="Enriched",
col=plt.col[2],adj=c(1,1))
      )

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

sheet<<-list(
  demo=list(
fun="plot",
call=list(
xlim=c(0,0.1),ylim=c(0,1.4),
main=annotate("Al2O3/SiO2 - MgO/SiO2 plot
  (Paulick et al. 2006)"
),
col="green",bg="transparent",fg="black",
xlab=annotate("Al2O3/SiO2"),
ylab=annotate("MgO/SiO2")),
template=temp
  )
)
}  

No comments:

Post a Comment