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!



Eye Tracking Geologists in the Field


Abstract: The history of eye-movement research extends back at least to 1794, when Charles Darwin’s grandfather, Erasmus Darwin, published “Zoonomia” which included descriptions of eye movements due to self-motion. For the next 200 years eye tracking research was to been confined to the laboratory. That all changed when Michael Land built the first wearable eyetracker at the University of Sussex and published a seminal paper  entitled “Where we look when we steer”. Inspired by Land’s work, a group cognitive scientists, computer scientists, computer engineers and geologists have been working to extend knowledge of how we actually use vision in the real world. I was fortunate enough to participate in this ground-breaking experiment earlier this year, and I wanted to share the experience with the geology community! In this blog article I will give a brief summary of the project I was involved in and the things I learned that can really help you be a better field geologist!


How do we look at a scene?
Most animals do not simply gaze at a scene – we simply don’t have the necessary resources to take in every single thing in front of us. Instead, our brains have developed a cunning cheat system whereby we target important aspects of a field of view and build up an image in our mind from the important selected areas. The bandwidth and processing power of our eye-brain circuitry need therefore only deal with a small portion of the image at once, and lots of interpolation can be done at source in the brain. This can be illustrated in the figure below:

Fig.1 Unlike birds, most animals build an image of the field of view before them by targeting important areas sequentially.

Fig.1 Unlike birds, most animals build an image of the field of view before them by targeting important areas sequentially.

Figure 1a shows what a field of view may “look” like to our brain before any fixations are made. Using our limited understanding of this new scene our brain may then target key areas of the field (fig. 1b-c) of view for further investigation. Fixations of varying durations and acquisition order are made, allowing our brain to, in real time, develop a better understanding of what is before the eyes. This process continues and continues the longer we look at a scene.

This process has been proven to be heavily influenced by the individual. The specific way we approach deconstructing this scene depends on a whole host of factors. This could be gender, intelligence, familiarity with the surroundings, experience with the scene, state of mind (distraction, tiredness) -basically any environmental factor that can affect the brain may change the way our brain and eyes go about investigating this scene. We may therefore use eye-tracking to see how different categories of people look at the same scene. To do this, eye-tracking software can gather the following information:

  • Fixation Points
    • Location, duration, sequence, saccade types
  • Pupil Dilation/constriction
  • Blinks

Eye tracking technology is therefore a powerful tool in cognitive research that may be used to access the brain. Here are some examples of common applications of eye-tracking:

  • Commercial Applications
    • User interface design
    • Marketing and product placement
    • Targeted marketing
  • Primate/infant/adult/geriatric research
  • Safety
    • Fatigue detection
    • Concentration detection
  • Sports Training
    • Motorsports
    • Ball sports
  • Accessibility
    • Communication tools for disabled people
    • Advanced methods for computer-human interaction
  • Medical
    • Laser Eye Surgery
    • fMRI, MEG, EEG

Eye-tracking is of particular interest to the commercial sector. Interestingly, commercial applications exploit the brain and the eyes: for instance, there’s a proven reason that advertisements at the top of the google search results page cost the most…

Heatmap of fixations of a google seach result page. (

So what does this have to do with geology? Well geologists are just one of many communities target by this new research. As mentioned in the abstract, eye tracking technology has only recently become mobile enough to be taken out of the laboratory and into the real world. Geologists are often confronted with new scenes in the field and must use their eyes and brains to really understand what it is that they are looking at. Therefore, by taking amateur and professional geologists into the field and conducting eye-tracking experiments, we can gain insights into differences in ways professionals and novices approach visual problems.

The Study of Geologists in the Field
A joint study between Rochester University and Rochester Institute of Technology (RIT) has for the past five years using a hefty NSF grant ($2m) to research geologists in the field. Principal investigators include Robert Jacobs, Jeff Pelz, and John Tarduno. The beautiful wearable eye-trackers were developed by Jason Babcock. The research has been conducted in a variety of environments, but the part that I took part in was a 10-day field excursion to the Western USA to visit some truly amazing geological localities.

First, lets take a look at the technology that I was wearing for the 10 days, and how it worked:

Backpack – Contains 1 Apple Mac Book Air, the powerhouse of the mobile eye-tracking unit and home to the custom-built processing software.


Head Unit – Contains a front-facing camera above the right eye, and an eye-facing camera and IR bulb for filming eye movements. Also we had to wear a ridiculously large sombrero to shield the cameras from direct sunlight.


Network – All the devices were connected to a local network, the router for which was being carried around here by Jeff Pelz. The custom software meant that he could use his iPhone to get real-time footage from any participants front-facing or eye-facing cameras at any time. This was useful for adjustments and also keeping participants looking where they should during experiments.


The Vans – The network extended back to the vans too. This van was the tech-van and contained massive hard drives for backing up all the data. Each evening, the RIT folk would sit in this van and process/backup the data.


Calibration – Each time we wore the mobile eye-tracking units, we had to complete a series of calibration exercises such that our fixations could be mapped onto the video of our front facing cameras. This was done by standing a few meters away from a calibration spot (as seen below on the back of Tomaso’s notebook) and rolling the head whilst keeping our eyes fixated on the spot. As if we didn’t look stupid enough!


Gigapan Images – Meanwhile, other members of the tech team were taking panoramic GigaPan images of each scene onto which the tracking data could be overlaid.


A typical stop would work something like this (somewhat similar to a roadside execution…):

  1. On approach to the locality we were told via radio not to look at the surroundings
  2. We’d get out of the vans, get the trackers on and calibrate
  3. Someone would then lead us to the viewing point – all the while we had to look down at our feet
  4. At the viewing point we would be given a question to address in our minds – often something like “What is the evidence this is a tectonically active area?”
  5. We were then told to look up and analyse the scene in silence for around a minute
  6. After the allocated time was up we then had to answer questions about what we had observed
  7. Following questions we would then be given an explanatory guide to the geology by John Tarduno

The Results
Unfortunately, I wasn’t allowed to know the conclusions of the study thus far during the trip – this would ruin the experiment. Similarly, if you ever think that you are going to have the chance to take part in a similar study – STOP READING NOW. Despite the lack of information I was privy to, I did manage to get some of the conclusions of the study from the authors before I left. What I am allowed to divulge is pretty intuitive, but may help you and even your students learn to analyse scenes better.

Put simply, professional geologists make fewer, longer and more systematic fixations when looking at scenes of interest. This makes sense – your brain targets the information in a scene that is going to tell you the most useful information to address the problem in mind: i.e. what’s the geological history of this outcrop? Conversely, the students in this experiment made lots and lots of short-lived fixations all over the scene in random places as they tried to search for something they might understand.  Here are some visualisations of the differences between students and experts.


The locality above is in Owens Valley, CA (36.60594N, 118.07511W) – fault scarp that resulted from an earthquake in 1872. It is has ca. 15ft of right lateral slip, and 8ft of vertical slip. As you can see from the image above, the expert realises that he/she is faced with a recent fault escarpment. The expert analyses the break in slope and the presence of the boulders on the escarpment. The novice, however, sees no significant feature in the dusty ground and looks to the mountains in the distance and local hills to see if there is anything obvious. The novice’s path of fixations is chaotic and short, returning to the same points briefly for no reason, then heading elsewhere.


The above scene is of a hanging valley located in Yosemite National Park (37.71769N, 119.64846W). The hanging valley represents the valley of a tributary glacier, and is now drainage for water. The cliff face represents the side of the valley calved by the main glacier – this main valley was deeper and so now the tributary valley “hangs”. The expert fixations for this spot are therefore right on the money. The expert looks at the slight u-shape to the hanging valley, acknowledges that there is still drainage here (reinforcing this is in some way a small valley), and the expert also notices the steep valley sides – likely caused by glacial activity. The novice however is distracted by the pretty rainbow and waterfall, and fails to see any real significant features in what to them is just a cliff face.

I had a great time in the USA taking part of the study, and I learned some new and reinforced some old really valuable field skills:

  • Make sure you do your research on the geological context of the area – we weren’t allowed to do much reading at all, and it really makes it tough when you are just dumped in a completely new tectonic/geological setting with no warning
  • Keep your eyes open all the time – even when driving from spot to spot. You should be gaining information all the time. Not being able to look around as we drove between stops was disconcerting and contributed the the difficulty of interpretation.
  • Have a question to answer in your mind – this gives the brain a guide when prioritising fixations
  • Make sure you can see properly – sunglasses and hats get distracting direct sunlight out of your eyes
  • PUT NOTEPAD AND PENCIL AWAY – just look. Sit there and just look and think. Then when you have understood more, start to draw.
  • When you see a feature you think might be interesting, feed it into your starting question: This is a bush… Does the bush give me evidence of recent tectonic activity? No. Stop looking at bushes.
  • Relate your stops to other useful resources – maps and satellite images. In the last example, it would be enlightening to see the broad and shallow valley atop the cliff.
  • If you find yourself looking all over the place – STOP. Start looking for lines and colour changes – i.e. topography and lithology changes. What are the key features? List them if you need to, even if you don’t understand their relevance.

Remember that your eyes don’t have a brain of their own. They are guided by what you know. If you don’t know anything, your eyes are not much use to you!

Thanks so much for reading! Please feel free to comment below!

R & GGPLOT – Expanded Plots

Learn how to create expanded inserts like this easily in R with this ggplot template.

Learn how to create expanded inserts like this easily in R with this ggplot template.


R and GGPLOT are great! There are some things, however, that I want to be able to do easily. For these things I have to create template codes, which I want to share with you!

This time around I wanted to show you how you can create “zoomed” areas of a plot and insert them into your main plot. This template will also show you how you can insert a completely different plot as an insert. This could be a table, map,….anything. This is a common thing to see in many plots, and alas now the functionality can be achieved easily.

DOWNLOAD TEMPLATE – Link to download from my script archive

Summary of the code:

  • You will define two plots: p1 and p2
    • p1 is the main plot – code it normally
    • p2 is the zoomed in area of p1 – the code for this is almost the same (see differences below)
    • p2 is placed inside of p1 and placed automatically into one of the corners that you specify
  • The differences between p1 and p2 are:
    • p1 has a rectangular grob defining the zoomed area – make sure the variables for its limits are linked to the customisation variables!
    • p2 has had the theme options changed to get rid of scales etc – we basically want the plot area to take up the entire device for p2, with no scales or padding.
  • Most of the customisation in the template is automated with variables – found at the top of the document
    • zoom – set the level of zoom
    • pad – set the padding of the insert
    • ex.col – fill colour of the expand boxes if you wish
    • ex.alpha – set this alpha to zero if you don’t want a fill
    • ex.lin – line colour of the zoom boxes
    • x.expand – the x range you wish to expand
    • y.expand – the y range you wish to expand
    • j.expand – the corner you wish the zoomed box to be in
    • ….other variables must be defined, but these are nicely laid out in a box at the top of the code
  • Awesome features of the code include
    • Aspect ratio is maintained for your zoomed area
    • Level of zoom can be easily defined – everything else is adjusted accordingly
    • The zoomed area is labeled with a zoom level
    • You can position the expanded box in any corner simply by defining j.expand as “tl” for Top Left etc – the computation of plotting coordinates is done automatically
    • Resolution is dynamic in the zoom box – so if you change your mind about zoom, it can be adjusted at 100% resolution – no loss

DOWNLOAD TEMPLATE – Link to download from my script archive

The code is easily customised, but pay attention to areas of code that are linked into customisation parameters. When you create your own code you should link in these variables into your plot to allow easy editing! To help you out with this, parts of the plot code that contain variables linked into the customisation parameters are commented with “#IMPORTANT“. As a general rule, though, follow this workflow:

  1. Create your base plot (p1)
  2. Define the rectangular grob (using customisation variables)
  3. Copy and use theme () options from p1 in the template
  4. Duplicate p1 to create p2
  5. Copy and use the theme () options for p2 from the template

If you have any questions, please don’t hesitate to comment. If you are having problems, provide simple examples of code which exhibit the problem you’re having and I’ll do my best to look at it!

Below are some edits of the code that show you how easily things can be changed…

zoom = 2.6

zoom = 2.6

pad = 3Screen Shot 2013-11-26 at 19.26.38

ex.lin = “red”

Screen Shot 2013-11-26 at 19.28.04

zoom = 5; pad = 1; x.expand = c(3, 4); y.expand = c(13, 16), j.expand = “br”

Screen Shot 2013-11-26 at 19.33.19

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.

#22 – Workflow for dynamic graphics

Screen Shot 2013-08-19 at 15.51.50

OK, so I’m a massive advocate of using LaTeX to create text documents for one main reason – they’re dynamic. If you change something in the source, it’s automatically changed in the document. This is why when I create R scripts for plots, I save them and the outputs in the LaTeX folder for the document. When I change the plot code, I don’t have to go make a duplicate in the LaTeX folder.

Anyway, you can build in the same workflow into your graphics design. If you’re making a poster or other graphic, simply “place” images into your document rather than copying and pasting them. Every time you change the original, it’s updated in graphic you’ve made. I’ve been doing this recently for my post for the Goldschmidt conference, and it’s been a real time saver since my data has remained dynamic right up until the day of printing!