Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plotSPC fudge factors #62

Closed
dylanbeaudette opened this issue Nov 21, 2018 · 2 comments
Closed

plotSPC fudge factors #62

dylanbeaudette opened this issue Nov 21, 2018 · 2 comments

Comments

@dylanbeaudette
Copy link
Member

dylanbeaudette commented Nov 21, 2018

The extra x and y space fudge factors should be dynamically adjusted based on, number of profiles and max depth. The current approach is rather crude and based on tinkering.

# padding along x-axis, prevents crowding
  # dynamic adjustment must also taking into account figure size
  # roughly 10% of length(x)
  extra_x_space <- length(x) * 0.1

  # 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
  if(max.depth <=50)
    extra_y_space <- 5
  if(max.depth > 50 & max.depth <= 100)
    extra_y_space <- 10
  if(max.depth > 100)
    extra_y_space <- 15

This is reasonable, but we can do better with a proper scaling function.

library(aqp)
d <- lapply(1:16, random_profile, n=c(6, 7, 8), n_prop=1, method='LPP')
d <- do.call('rbind', d)
depths(d) <- id ~ top + bottom
explainPlotSPC(d)

image

library(aqp)
data(sp4)
depths(sp4) <- id ~ top + bottom
explainPlotSPC(d)

image

dylanbeaudette added a commit that referenced this issue Nov 21, 2018
@dylanbeaudette
Copy link
Member Author

Note that the current scaling logic doesn't work well when n < 4, and output is not acceptable when n <=2.

@dylanbeaudette
Copy link
Member Author

dylanbeaudette commented Nov 27, 2018

A reasonable work-around for n = 1 and tall-narrow output.

image

Move sketch over 0.5 index units, make room for 2 profiles, adjust profile width accordingly.

library(soilDB)
x <- fetchOSD(c('amador', 'pentz', 'auburn', 'hornitos'))
# trick plotSPC into a reasonable figure
explainPlotSPC(x[1, ], x.idx.offset=0.5, n=2, width=0.35)

image

For production use you could get away with an even stranger hack:

par(mar=c(0,0,1,2))
plot(x[1, ], x.idx.offset=0.5, n=2, width=0.4, cex.names=1, y.offset=-10, scaling.factor=1.15)

I still think we need a better option for n == 1 and n<4. This is #59. Started work in R/sketch.R.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant