Skip to content

Commit

Permalink
feat: error margins can now be plotted for numeric x vars, not only f…
Browse files Browse the repository at this point in the history
…actors
  • Loading branch information
m-jahn committed Nov 24, 2023
1 parent db6446f commit a5326b4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
9 changes: 7 additions & 2 deletions R/panel_barplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,13 @@ panel.barplot <- function (x, y,
}

x_s <- unique(x_sub)
if (is.factor(x_s)) x_s <- sort(as.numeric(x_s))
if (beside) x_pos <- x_s + nudge[val] else x_pos <- x_s
if (is.factor(x_s)) {
x_s <- sort(as.numeric(x_s))
if (beside) x_pos <- x_s + nudge[val] else x_pos <- x_s
} else {
if (beside) x_pos <- x_s + nudge[val] else x_pos <- x_s
x_s <- order(x_s)
}
if (is.null(origin)) ybottom <- current.panel.limits()$ylim[1]
else ybottom <- origin

Expand Down
10 changes: 8 additions & 2 deletions R/panel_errbars.R
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,14 @@ panel.errbars <- function (x, y,
}

x_s <- unique(x_sub)
if (is.factor(x_s)) x_s <- sort(as.numeric(x_s))
if (beside) x_pos <- x_s + nudge[val] else x_pos <- x_s
if (is.factor(x_s)) {
x_s <- sort(as.numeric(x_s))
if (beside) x_pos <- x_s + nudge[val] else x_pos <- x_s
} else {
if (beside) x_pos <- x_s + nudge[val] else x_pos <- x_s
x_s <- order(x_s)
}


Y <- as.matrix(cbind(means, means-lower, means+upper))
y_s <- Y[x_s, 1]
Expand Down

0 comments on commit a5326b4

Please sign in to comment.