4

I am producing a stratigraphy plot which should look something like the following

enter image description here

I've got to the point where I can plot the layout of the plot using some dummy data and the following code

Strat  <- c(657,657,657,657,657,657,657,657,657,657,601,601,601,601,601,601,601,601,601,601,610,610,610,610,610,610,610,610,610,610)
Distance <- c(7.87,17.89,22.09,42.84,50.65,55.00,65.74,69.38,72.36,75.31,7.87,17.89,22.09,42.84,50.65,55.00,65.74,69.38,72.36,75.31,7.87,17.89,22.09,42.84,50.65,55.00,65.74,69.38,72.36,75.31)
Altitude <- c(565.05,191.98,808.12,609.19,579.10,657.08,708.00,671.44,312.10,356.14,565.05,191.98,808.12,609.19,579.10,657.08,708.00,671.44,312.10,356.14,565.05,191.98,808.12,609.19,579.10,657.08,708.00,671.44,312.10,356.14)
strat_max <- c(565.05,191.98,808.12,609.19,579.10,657.08,708.00,671.44,312.10,356.14,565.04,176.23,795.52,608.06,567.89,641.83,698.69,664.50,310.21,350.11,526.47,147.30,762.49,601.99,544.22,632.54,689.33,636.40,282.71,313.56)
strat_min <- c(565.04,176.23,795.52,608.06,567.89,641.83,698.69,664.50,310.21,350.11,526.47,147.30,762.49,601.99,544.22,632.54,689.33,636.40,282.71,313.56,463.31,81.01,718.11,594.38,539.53,616.18,670.79,602.96,249.59,289.63)
strat <- cbind(Strat, Distance, Altitude, strat_max, strat_min)
strat <- as.data.frame(strat)

attach(strat)
ggplot(strat, aes(x=Distance, y=Altitude, colour=factor(Strat))) +
  geom_linerange(aes(x=Distance, ymax=strat_max, ymin=strat_min, colour=factor(Strat)), lwd=10) +
  geom_line(lty=1, lwd=1.5, colour="black") +
  xlab("Distance") + ylab("Altitude") +
  theme_bw() + scale_colour_discrete(name="Stratigraphy Type")

plot so far

However, I have been unable to add the relevant patterns. Each rock/ sediment type has a standard plotting pattern for use in stratigraphic plots from the USGS and I would like to relate the code in strat$Strat to the relevant pattern and use that as the pattern

USGS Swatches

Does anyone know how to import these (e.g. as PNG files) and then use them as patterns? I had thought to try and call them as colours but I don't know if that would work and there's probably no framework for telling R how to repeat them. Currently I am writing the plot as shown and then adding in the patterns in adobe illustrator

Any insight appreciated!

scoa
  • 19,359
  • 5
  • 65
  • 80
James Bell
  • 73
  • 7
  • It may be possible to use grid.raster() to map specific images to certain areas of the plot - does anyone know if I can tell it to overlay specific areas of the plot – James Bell Oct 06 '15 at 15:19
  • 1
    I'm not sure this is possible yet (in ggplot). See comments here: http://stackoverflow.com/questions/21338103/filling-bars-in-barplot-with-textiles-in-ggplot2 and the thread here: https://groups.google.com/forum/#!topic/ggplot2/62T0RYtWz38. A bit dated, but couldn't find anything more recent. The last word from Hadley is that it conflicts with the grid system used for rendering – Chris Oct 06 '15 at 17:21
  • Thanks Chris, I'm currently looking into a workaround using lattice. Got one image filling the bars! – James Bell Oct 07 '15 at 20:07
  • Make sure to update the answer if you find it! – Chris Oct 07 '15 at 20:18
  • `ggtextures` (on github) gives a route towards solving this problem – Richard Telford Nov 30 '18 at 10:16
  • This should help https://stackoverflow.com/questions/26110160/how-to-apply-cross-hatching-to-a-polygon-using-the-grid-graphical-system/26110400#26110400 – Andre Wildberg Jan 03 '21 at 12:59

0 Answers0