Skip to content

Commit

Permalink
use xlim from plotSPC(), requires latest aqp for this to work, temp f…
Browse files Browse the repository at this point in the history
…ix in place for older aqp
  • Loading branch information
dylanbeaudette committed Jul 12, 2024
1 parent 4e64c66 commit 461d141
Showing 1 changed file with 36 additions and 2 deletions.
38 changes: 36 additions & 2 deletions R/plotGeomorphCrossSection.R
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ plotGeomorphCrossSection <- function(x, type = c('line', 'bar'), g = 'hillpos',
cex.id = ifelse(!is.null(.opArgs$cex.id), .opArgs$cex.id, 0.55),
hz.distinctness.offset = 'hzd'
)

# appropriate xlim for plotting region setup by plotProfileDendrogram()
x.lim <- c(0.5, length(o$SPC) + 1)

} else {
# profiles only
plotSPC(
Expand All @@ -122,6 +126,18 @@ plotGeomorphCrossSection <- function(x, type = c('line', 'bar'), g = 'hillpos',
cex.id = ifelse(!is.null(.opArgs$cex.id), .opArgs$cex.id, 0.55),
hz.distinctness.offset = 'hzd'
)

# get plotting details from aqp environment
lsp <- get('last_spc_plot', envir = aqp.env)
x.lim <- lsp$xlim


## TODO: temporary fix until latest aqp is on CRAN
# close approximation
if(is.null(x.lim)) {
x.lim <- c(0.5, length(o$SPC) + 1)
}

}

# bottom panel
Expand All @@ -135,7 +151,7 @@ plotGeomorphCrossSection <- function(x, type = c('line', 'bar'), g = 'hillpos',
col = col,
xlab = '',
ylab = '',
xlim = c(0.5, length(o$SPC) + 1)
xlim = x.lim
)

# proportion axis
Expand Down Expand Up @@ -172,6 +188,10 @@ plotGeomorphCrossSection <- function(x, type = c('line', 'bar'), g = 'hillpos',
cex.id = ifelse(!is.null(.opArgs$cex.id), .opArgs$cex.id, 0.55),
hz.distinctness.offset = 'hzd'
)

# appropriate xlim for plotting region setup by plotProfileDendrogram()
x.lim <- c(0.5, length(o$SPC) + 1)

} else {
# profiles only
plotSPC(
Expand All @@ -184,9 +204,20 @@ plotGeomorphCrossSection <- function(x, type = c('line', 'bar'), g = 'hillpos',
cex.id = ifelse(!is.null(.opArgs$cex.id), .opArgs$cex.id, 0.55),
hz.distinctness.offset = 'hzd'
)

# get plotting details from aqp environment
lsp <- get('last_spc_plot', envir = aqp.env)
x.lim <- lsp$xlim

## TODO: temporary fix until latest aqp is on CRAN
# close approximation
if(is.null(x.lim)) {
x.lim <- c(0.5, length(o$SPC) + 1)
}
}



# setup barplot
sp <- c(1.5, rep(1, times = length(o$SPC) - 1))
barplot(
Expand All @@ -198,7 +229,7 @@ plotGeomorphCrossSection <- function(x, type = c('line', 'bar'), g = 'hillpos',
axes = FALSE,
xlab = '',
ylab = '',
xlim = c(0.5, length(o$SPC) + 1),
xlim = x.lim,
ylim = c(0, 1.2)
)

Expand All @@ -223,6 +254,9 @@ plotGeomorphCrossSection <- function(x, type = c('line', 'bar'), g = 'hillpos',
on.exit({
# reset original plotSPC options
options(.aqp.plotSPC.args = .opArgs)

# for R CMD check
aqp.env <- NULL
})

}
Expand Down

0 comments on commit 461d141

Please sign in to comment.