Skip to content

Commit

Permalink
tweaks related to #62
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanbeaudette committed Nov 26, 2018
1 parent b1115ea commit ba438e4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 5 additions & 4 deletions R/explainPlotSPC.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# useful for debugging plotSPC
explainPlotSPC <- function(x, ...) {
plot(x, id.style='side', ...)
box()

# get last plot parameters
lsp <- get('last_spc_plot', envir=aqp.env)
Expand Down Expand Up @@ -34,12 +35,12 @@ explainPlotSPC <- function(x, ...) {
segments(x0 = 1:length(x), x1=1:length(x), y0=lsp$max.depth, y1=scaled.max.depths, lty=3, lwd=2, col='darkgreen')

# profiles are centered at integers, from 1 to length(obj)
axis(1, line=0, at=1:lsp$n, cex.axis=0.75, font=4, col='darkgreen', col.axis='darkgreen', lwd=2)
mtext('canvas x-coordinate', side=1, line=2, font=4, col='darkgreen')
axis(1, line=0.25, at=1:lsp$n, cex.axis=0.75, font=4, col='darkgreen', col.axis='darkgreen', lwd=2)
mtext('canvas x-coordinate', side=1, line=2.25, font=4, col='darkgreen')

# y-axis is based on profile depths
axis(2, line=-1, at=scaled.depth.axis, cex.axis=0.75, font=4, las=1, col='blue', col.axis='blue', lwd=2)
mtext('canvas y-coordinate', side=2, line=1, font=4, col='blue')
axis(2, line=0.25, at=scaled.depth.axis, cex.axis=0.75, font=4, las=1, col='blue', col.axis='blue', lwd=2)
mtext('canvas y-coordinate', side=2, line=2.25, font=4, col='blue')

# show extra y-space
arrows(x0=y.space.x, x1=y.space.x, y0=0, y1=-lsp$extra_y_space, length = 0.08, code = 3, col='orange', lwd=1)
Expand Down
4 changes: 4 additions & 0 deletions R/plotSPC.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ plotSPC <- function(x, color='soil_color', width=0.2, name=NULL, label=idname(x)
# dynamic adjustment must also taking into account figure size
# roughly 10% of length(x)
extra_x_space <- length(x) * 0.1

# add a little extra x-space when n < 5
if(length(x) < 5)
extra_x_space <- extra_x_space + 0.25

# padding above profiles, ~ 15 is about right for n in {1,25} and max depth near 150cm
# a sketch of shalllow profiles could benefit from ~ 5
Expand Down

0 comments on commit ba438e4

Please sign in to comment.