Skip to content

Commit 25f738b

Browse files
committed
little tweak for 1d opt.state plottign
1 parent f0ef0ea commit 25f738b

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

R/plot_OptState.R

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ plot.OptState = function(x, scale.panels = FALSE, ...) {
5959
# prepare data for ggplot2
6060
mdata = data.table::melt(plot.data, id.vars = x.ids)
6161
mdata$variable = factor(mdata$variable, levels = intersect(use.only.columns, levels(mdata$variable)))
62-
if (scale.panels) {
62+
if (scale.panels && par.dim == 2) {
6363
predict.range = range(mdata[get("variable")=="mean", "value"])
6464
mdata[, ':='("value", normalize(x = get("value"), method = "range")), by = "variable"]
6565
design[[y.ids]] = (design[[y.ids]] + (0 - predict.range[1])) / diff(predict.range)
@@ -82,7 +82,11 @@ plot.OptState = function(x, scale.panels = FALSE, ...) {
8282
} else {
8383
formula.txt = "~variable"
8484
}
85-
g = g + ggplot2::facet_grid(as.formula(formula.txt))
85+
if (scale.panels && par.dim == 1) {
86+
g = g + ggplot2::facet_wrap(as.formula(formula.txt), nrow = 1, scales = "free_y")
87+
} else {
88+
g = g + ggplot2::facet_grid(as.formula(formula.txt))
89+
}
8690
}
8791
g = g + ggplot2::scale_shape_manual(values = c(init = 16, seq = 15))
8892
g

0 commit comments

Comments
 (0)