Actions for iPad – Awesome productivity enhancement


There are lots of reasons people like us may want a tablet. Save the endless discussions between Appleists and Antiappleists for somewhere else, here is a GREAT app for the iPad to increase your productivity when at your desk.

In a nutshell, Actions lets you execute chains or single instances of the following just by clicking an icon on the app’s screen:

  • Keyboard shortcuts
  • Paste snippets of text
  • Control media (play, pause etc)
  • System commands (Desktop, screensaver, shutdown etc)
  • Window commands (Hide, maximise, fill right etc)
  • Navigate to URL
  • Or any combination of the above

Watch this youtube video for the overview of the app and then visit the Actions for iPad app homepage to download the app.

I find the most useful commands are those which paste snippets of text. This includes pasting common functions, preambles and code structures. Take a look at my buttons for different coding apps for ideas:

Snippets can be short or long, and you can transfer the code snippet from your computer to the app just by copying (on the computer) and pasting (in the app). However if you’re looking for some preset functions, you can load some preset commands for common applications like Illustrator and Firefox.


Have a go and get back to me if you find some ways in which this app can be even more useful to coders and geocomputers!


Ternary Plots in GGPLOT/R

Ternary Plot using ggplot2


Ternary plots are great for displaying trivariate data (or more), and are used a lot in geochemistry. R is a great tool for plotting data and has built-in capabilities for dealing with trivariate data:

Many people, however, use the ggplot2 package for R which sadly has no native ternary plotting capability. A hack is provided by Sean Mulcahy, but the code here deals with an alternative, somewhat adapted way of achieving similar results.

How does it work? Basically the code takes 3 variables (A, B, C) and converts it into XY data. The ternary plot is actually plotted on a [hidden] X-Y plot, where the X values are corrected for Y thus allowing ternary data to be plotted onto the XY plot area.

Features of the template

  • Lists of common customisation parameters (colour, size etc) built into the preamble to make visual changes quick and correct
  • Automatic correction of ABC data into ternary plotting coordinates
  • Systematically commented allowing you to understand what’s doing what.

What next? I’m working on a set of templates for common geochemical discrimination diagrams which will allow you to simply import and display your data and discriminate between your samples.

# Load Packages
	library (cwhmisc)
	library (ggplot2)
	library (grid)
	library (scales)

# Select Data Source 
	# Select csv file
	data = mtcars	
	# Define apices
	#t = top, l = left, r = right
	data$l = data$mpg		# e.g. data$t = data$a*100
	data$t = data$wt*10
	data$r = data$hp/5

# Plot customisation
	# Customise: Colours
	colour.1 = "white"		# Panel background colour
	colour.2 = "white"		# Plot area background colour
	colour.3 = "black"		# Outer text colour
	colour.4 = "black"		# Plot outline colour
	colour.5 = "lightgrey"		# Gridline colour
	colour.6 = "white"		# Legend box outline colour
	# Customise: Font sizes
	fs.r = 1.168
	fs.1 = 6
	fs.2 = (fs.1*2) * (fs.r^4)
	fs.3 = fs.1 * (fs.r^5)
	# Labels & Title
	title = "Ternary Template v.09.13"
	apices = c("MPG", "Horse Power", "Weight (x10)") 	# Left, Right, Top

	# Other
	gridlines = F		# Turn gridlines on/off with T/F


# Convert data to %
	data$total = data$l+data$r+data$t
	data$t = (data$t/data$total)*100
	data$l = (data$l/data$total)*100
	data$r = (data$r/data$total)*100

# Convert abc into xy
	data$x = (100-((data$t/2)+((100-data$t)*(data$l/(data$l+data$r)))))
	data$y = data$t

	#if t = 100 then x should be 50 
	n = nrow (data)
	for (i in 1:n) {
		temp = data[i,]
		if (temp$y == 100) {temp$x = 50}
		data[i,] = temp	

# Coordinates for triangle
	tri = data.frame (c(0, 100, 50, 0), c(0, 0, 100, 0))
	colnames(tri) = c("x", "y")

# Coordinates for grid
	x1 = seq (10, 90, 10)
	x2 = seq (5, 45, 5)
	x3 = seq (55, 95, 5)
	x4 = seq (45, 5, -5)
	y1 = 0
	y2 = seq (10, 90, 10)
	y3 = seq (90, 10, -10)
	grid = data.frame (x1, x2, x3, x4, y1, y2, y3)

# Open new quartz window (height = 10*0.866025, width = 10)
	if (gridlines == T) {gridalpha = 1} else {gridalpha = 0}

ggplot (data = data, aes (x = x, y = y)) +
	# Shapes, lines, text
	geom_polygon (data = tri, fill = colour.2) +
	geom_segment (data = grid, 
		aes (x = x1, y = y1, xend = x2, yend = y2), 
		linetype = "dashed", size = 0.5, colour = colour.5, alpha = gridalpha) +
	geom_segment (data = grid, 
		aes (x = x1, y = y1, xend = x3, yend = y3), 
		linetype = "dashed", size = 0.5, colour = colour.5, alpha = gridalpha) +
	geom_segment (data = grid, 
		aes (x = x4, y = y3, xend = x3, yend = y3), 
		linetype = "dashed", size = 0.5, colour = colour.5, alpha = gridalpha) +
	annotate ("text", label = apices, x = c(-5, 105, 50), y = c(-5, -5, 105), size = fs.1, colour = colour.3) +
	labs (title  = title, colour = "No Cylinders") +
	geom_path (data = tri, size = 0.5, colour = colour.4) +
	# Appearance controls
	coord_fixed (ratio = 0.866025) +
	scale_x_continuous (limits = c(-20, 120), expand = c(0,0)) +
	scale_y_continuous (limits = c(-20, 120), expand = c(0,0)) +
	theme (
		# Panel and plot attributes
		plot.title = element_text (size = fs.2, colour = colour.3), 	# Plot title
		plot.margin = unit (c(3, 4, 3, 3), "lines"), 					# Plot margins
		plot.background = element_rect (colour = F, fill = colour.1),
		panel.border = element_rect (colour = F, fill = F, size = 1), 	# Axis colours
		panel.grid.major = element_blank (), 							# Remove major grid
		panel.grid.minor = element_blank (), 							# Remove minor grid
		panel.background = element_rect (fill = colour.1), 				
		# Legend attributes
		legend.background = element_rect (colour = colour.6, size = 0.3, fill = "white"),
		legend.justification = c(1, 1),
		legend.position = c(0.9, 0.9), 				# Put the legend INSIDE the plot area
		legend.key = element_blank (), # switch off the rectangle around symbols in the legend = "bottom", = "horizontal",
		legend.title = element_text (size = fs.3, colour = colour.3), # switch off the legend title
		legend.text = element_text (size = fs.3, colour = colour.3), #sets the attributes of the legend text
		# Axis attributes
		axis.title.x = element_blank (),
		axis.title.y = element_blank (),
		axis.text.x = element_blank (),
		axis.text.y = element_blank (),
		axis.ticks = element_blank ()
		) +
	# Data layer
	geom_point (aes(colour = factor(cyl)),size = 6)

ggsave ("/Users/s0679701/Desktop/ternary.png", dpi = 100)

Update: Basic R Template


Here is an update to my basic template for R using ggplot2.

Updates include

  • Added size scaling, using golden ratios
  • Updated padding
  • Updated aspect ratio fixing

Click here to download the R file.

The code is displayed below:

# R Template v.09.13
# Compiled by Darren J Wilkinson
# The University of Edinburgh, Scotland

# Packages to load
library (ggplot2)
library (grid)
library (scales)

# Easy customisation parameters

	# Text/Line/Fill Colours
	colour.1 = "black"		# Text, outside plot area
	colour.2 = "white"		# Fill, outside plot area
	colour.3 = "white"		# Fill, plot area
	colour.5 = "black"		# Text, inside plot area
	colour.6 = "black"		# Outlines

	# Line Widths
	lw.r = 1.1618			# Scaling ratio
	lw.1 = 1.5				# Plot area
	lw.2 = lw.1/(lw.r^7)	# Axis ticks
	lw.3 = lw.1/(lw.r^8)	# Legend box

	# Font Sizes
	fs.r = 1.1618				# Scaling ratio
	fs.1 = 12					# Axis Labels
	fs.2 = fs.1 * (fs.r^2)		# Axis title
	fs.3 = fs.1 * (fs.r^3)		# Plot title
	fs.4 = fs.1 / (fs.r^2)		# Legend
	fs.5 = fs.1 / (fs.r^4)		# Legend title

# Plot Code

	# Define the plot
	ggplot (
		data = mtcars, 
		aes (
			x = wt,
			y = mpg
		) +

	# Data layers
	geom_point (
			colour = hp
		size = 4
		) +

	# Customise: Scales
	scale_x_continuous (name = "Mass (Tonnes)") +
	scale_y_continuous (name = "Miles per Gallon (MPG)") +	

	# Customise: Labels
	labs (
		title = "Template v.09.13",
		colour = "Horse\nPower (HP)"
		) +

		scale_colour_gradient (high = "red", low = "grey") +

	# Customise: Appearance
	theme (
		# Plot Attributes
		plot.title = element_text (vjust = 3, size = fs.3, colour = colour.5),
		plot.margin = unit (c(5, 2, 5, 3), "lines"), 								# Plot padding
		plot.background = element_rect (fill = colour.2, colour = F),

		# Panel Attributes
		panel.border = element_rect (colour = colour.6, fill = F, size = lw.1), 		
		panel.grid.major = element_blank (), 										# Removes major grid
		panel.grid.minor = element_blank (),  										# Removes minor grid
		panel.background = element_rect (fill = colour.3, colour = colour.2), 		

		#Legend Attributes
		legend.background = element_rect (colour = colour.6, size = lw.3, fill = colour.3),
		#legend.justification = c(0, 0),							# (1/2) Uncomment to place lnd inside plot area
		#legend.position = c(0, 0), 								# (2/2) Uncomment to place lnd inside plot area
		legend.key = element_blank (), 									# Remove bkgrd for legend elements
		legend.title = element_text (size = fs.4, colour = colour.1),
		legend.text = element_text (size = fs.5, colour = colour.1),	

		# Axis Attributes
		axis.title.x = element_text (vjust = -2, size = fs.2, colour = colour.5), 
		axis.title.y = element_text (vjust = -0.1, angle = 90, size = fs.2, colour = colour.5), 
		axis.text.x = element_text (size = fs.1, vjust = -0.25, colour = colour.5), 
		axis.text.y = element_text (size = fs.1, hjust = 1, colour = colour.5), 
		axis.ticks = element_line (colour = "black", size = lw.3),
		axis.ticks.length = unit(-(0.5/(1.168^4)) , "cm"), 
		axis.ticks.margin = unit(0.5, "cm"),

		# Other Attributes
		aspect.ratio = 1/1.168

Goldschmidt Poster Supplement



[1] Barth, M G; McDonough, W F; Rudnick, R. Tracking the budget of Nb and Ta in the continental crust. Chemical Geology, 165, pp 193-213. 2000.

[2] Peacock, S M; Large-scale hydration of the lithosphere above subducting slabs. Chemical Geology, 108, pp. 49-59. 1993.

[3] Nui, Y. Bulk-rock major and trace element compositions of abyssal peridotites: Implications for mantle melting, melt extraction and post-melting processes. Journal of Petrology, 45, pp 2423-2458.

[4] Xiao, Y; Lavis, S; Nui, Y; Pearce, J A; Lui, H; Wang, H; Davidson, J. Trace element transport during subduction zone ultra high pressure metamorphism: evidence from Western Tishan, China. GSA Bulletin, 124, pp 1113-1129.

[5] Zack, T and John, T. An evaluation of reactive fluid flow and trace element mobility in subducting slabs. Chemical Geology, 239, pp 397-216.

[6] Pearce, J A. A users guide to basalt discrimination diagrams. In Wyman, D A, “Trace element geochemistry of volcanic rocks: applications for massive sulphide exploration”, GAC, short course notes, 12, pp 79-1134.

#17 Homage to the Sausage – Be the Boudin


Geologist Tom Challands and his unique interpretation of “be the boudin”.

In the North West Highlands of Scotland, there’s a stretch of coastline graced with the, often understated, natural beauty of creamy soft sands and tempting turquoise water, and bedrock that tells a story far more captivating than man has ever written for himself.

Much of the lowlands here are made of grey metamorphic “Lewisian” gneisses that record some of the earliest parts of Earth’s history available in the rock record. A world so old and foreign that it’s amazing we can tell anything about it at all.


Suilven mountain, from the road to Clachtoll. Sulven is made of near horizontally bedded arkosic sandstones, deposited onto the hummocky lowlands of Lewisian gneiss.

A common feature of the gneisses are textures that tell a story of stretching in conditions deep and hot enough to reach the point at which rock deforms like soft toffee. Harder, darker layers made of minerals rich in iron and magnesium minerals (a.k.a. mafic) respond differently to deformation compared to the lighter layers made of minerals richer in silica (a.k.a. felsic). The contrast in response to extensional deformation result in the breaking up of the darker layers into chains of sausages (aka. boudinage). Each individual block, often lensoidal in shape, is known as a boudin (i.e. sausage).

These boudinaged dark layers in the gneisses are common not just here, but in geologically similar areas around the world, and can be seen on scales of a few millimetres to many tens of meters.


Boudinaged layers in gneiss. Note the darker layers have begun to break up into blocks in a disarticulated chain.

Boudinaged mafic layers in gneiss, Kangerlussuaq, Greenland.

Boudinaged mafic layers in gneiss, Kangerlussuaq, Greenland.

At the beach of Achmelvich (58.172915, -5.302604, [map]), arguably one of Britain’s most stunning beaches, you find gneisses which show clear evidence of the type of deformation mentioned above. There, the gneisses are folded, re-folded, and folded again into a complex, contorted basement which has been the subject of intense unravelling by geologists for over a hundred years.


Achmelvich Beach (58.172915 N, -5.302604 W), arguably one of Britain’s most beautiful beaches.

As you turn you back to the  shining blue sea and the clean cream sands, you find a crag with a whole set of these boudinaged dark layers. The brunt of the sea has, over thousands of years, gouged and gouged at this face. The pummelling and battering of the crag has plucked out one of these boudins, a pip of darker rock, leaving a pseudomorph of the former rocky sausage.

The half-egg shaped recession in the cliff is actually a surprisingly perfect perch for the derrière of most beach dwellers or geological guests, and has over the years been used for such a purpose.


Myself having a rather traumatic boudinage birthing experience.

Myself having a rather traumatic boudinage birthing experience.

Geologist Madeleine Berg during her first boudinisation.

Geologist Madeleine Berg during her first boudinisation.

But alas, the boudin is nowhere to be seen, and the perch is there like a memorial to the former knocker which ironically got knocked out. Almost in tribute to the boudin, geologists visiting the beach began paying their respects by assuming the form of the boudin for a brief, but immensely symbolic moment. For not only is this a sign of geological respect, homage to the “saus-age”, it has become an important ritual of initiation which marks a milestone in ones geological career. A milestone which will divide ones life into pre- “birth by boudin” (BBB) and post-BBB.

The first geologists to “be the boudin” were Nigel Kelly and Simon Harley. Simon is a regular visitor to the beach and overseas and encourages in the ritual with new geologists every year.

So, should you wonder out yonder, please have a ponder, on the act of birth by a boudin. And when you have, drop me a line and a photo so that we may appreciate your “be the boudin”!

#1 ICP-MS: Not a new fusion preparation technique

The tetragonal structure of rutile.

The tetragonal structure of rutile, a heavy accessory mineral.

Eclogites, although pretty rocks, can provide analytical challenges due to their unique mineralogy. This post discusses one of those problems and how I tried to overcome it… before I realised the problem wasn’t actually a problem.

The Problem
Eclogites typically contain rutile. Some, such as the Engebøfjellet eclogite in Norway contain economic deposits of the stuff. Rutile can contain up to 95 % of the whole rock’s inventory of important trace elements (e.g. Nb, Ta, HFSEs) useful in fingerprinting the igneous protolith. The refractory nature of eclogite, however, means that it is somewhat hard dissolve and melt. Thus, when dissolving whole rock eclogite powders for ICP-MS analysis, using a series of powerful acids, how does one know you are actually dissolving the rutile? I needed to find an alternative method that I thought would potentially increase the dissolution of rutile during preparation. Continue reading

Welcome to my blog!

Thanks for visiting! I’ve created this blog after seeing and hearing the great benefits my peers have had with blogging. Attempting to diverge away from the old fashioned approach to self promotion operated by many in my field of the older generation, I hope this blog will reach the people whom I want to reach most.

But Darren, what on Earth will you blog about?
As the header of this page suggests, I class myself under a number of professions. First and foremost I am a geologists and so that will be the main theme of this blog. The blogs will be, however, so much more. I will blog on software techniques, news and findings relevant to everyone in the field of Earth Science and beyond.

So here goes!