Skip to content

Commit

Permalink
Merge pull request #10 from m-jahn/dev
Browse files Browse the repository at this point in the history
feat: error margins can now be plotted for numeric x vars, not only factors
  • Loading branch information
m-jahn authored Nov 26, 2023
2 parents db6446f + a5326b4 commit 3b9aa04
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 3b9aa04

Please sign in to comment.