2016-07-06 35 views
1

如何手動調整地層圖中特定面板的x軸基線位置?在地層圖上更改基線位置

例如,這裏的Stratiplot從模擬:

library(analogue) 
data(V12.122) 
Depths <- as.numeric(rownames(V12.122)) 

(plt <- Stratiplot(Depths ~ O.univ + G.ruber + G.tenel + G.pacR, 
        data = V12.122, type = c("h","l","g","smooth"))) 

enter image description here

我如何可以設置面板G.麴黴的基準,以便它被設置爲0.4,而不是0,因爲我們看到上面的情節?

這意味着條起始於0.4,值> 0.4將在基線右側,並且值< 0.4將落在基線左側。

可能相關的:Change x-axis limits on stratigraphic plots (ie. multi-panel plots)

回答

1

這是一個有點骯髒的黑客,但是,在Q &一個你聯繫的精神,這裏有一個方法來實現這一目標:

# Create a dummy variable with the offset (you can also rewrite the column instead) 
V12.122$G.ruber.mod <- V12.122$G.ruber-0.4 
# Plot as normal 
(plt <- Stratiplot(Depths ~ O.univ + G.ruber.mod + G.tenel + G.pacR, 
        data = V12.122, type = c("h","l","g","smooth"))) 
# Modify the range so that it takes negative values 
plt$x.limits[[2]] <- range(V12.122$G.ruber.mod, na.rm = TRUE) 
# Modify where the labels are drawn for that plot: 
plt$x.scales$at <- list(O.univ=FALSE, 
         G.ruber.mod=seq(-.1,.1,by=.05), 
         G.tenel=FALSE, 
         G.pacR=FALSE) 
# Modify what the labels says for that plot: 
plt$x.scales$labels <- list(O.univ=FALSE, 
         G.ruber.mod=seq(-.1,.1,by=.05) + 0.4, 
         G.tenel=FALSE, 
         G.pacR=FALSE) 
# Replot: 
latticeExtra::resizePanels(plt, w=c(5,5,5,5)) 

Resulting plot

+0

非常感謝,這正是我所需要的。 – Ben