使用图像文件作为R中的绘图模式

时间:2015-10-06 15:00:15

标签: r ggplot2

我正在制作一个地层图,看起来应该如下所示

enter image description here

我已经到了可以使用一些虚拟数据和以下代码绘制绘图布局的点

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

但是,我无法添加相关模式。每种岩石/沉积物类型都有一个标准的绘图模式,用于USGS的地层图,我想将strat $ Strat中的代码与相关模式联系起来,并将其用作模式

USGS Swatches

有谁知道如何导入这些(例如作为PNG文件),然后将它们用作模式?我曾经想过尝试将它们称为颜色,但我不知道这是否有用,并且可能没有框架告诉R如何重复它们。目前我正在编写如图所示的情节,然后在adobe illustrator中添加模式

任何洞察力都赞赏!

0 个答案:

没有答案