Skip to content

Commit

Permalink
fix plot axes for and ; closes #213
Browse files Browse the repository at this point in the history
  • Loading branch information
Enchufa2 committed Feb 20, 2021
1 parent b88ecdd commit 8b0ccc8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
* add `keep_units`, a helper to apply functions that do not preserve units;
#255 addressing #252

* fix plot axes for `plot.formula` and `plot.data.frame`; #213

* fix arithmetic for powers above 1 and below -1; #264

* improve arithmetic of logarithms; #249
Expand Down
14 changes: 8 additions & 6 deletions R/plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ plot.units <- function(x, y, xlab = NULL, ylab = NULL, ...) {
# We define the axis labels if they are not already provided and then let
# the default plotting function take over...
xlab0 = paste(deparse(substitute(x), 500), collapse = "\\n")
ylab0 = paste(deparse(substitute(y), 500), collapse = "\\n")
if (missing(y)) { # from xy.coords:
if (is.null(ylab))
ylab <- make_unit_label(deparse(substitute(x)), x)
Expand All @@ -82,12 +83,13 @@ plot.units <- function(x, y, xlab = NULL, ylab = NULL, ...) {
x <- seq_along(x)
return(NextMethod("plot", x, y, xlab=xlab, ylab=ylab))
}
if (is.null(xlab)) {
xlab <- make_unit_label(xlab0, x)
}
if (is.null(ylab) && inherits(y, "units")) {
ylab <- make_unit_label(deparse(substitute(y)), y)
}
if (is.null(xlab))
xlab <- xlab0
if (is.null(ylab))
ylab <- ylab0
xlab <- make_unit_label(xlab, x)
if (inherits(y, "units"))
ylab <- make_unit_label(ylab, y)
NextMethod("plot", xlab=xlab, ylab=ylab)
}

Expand Down

0 comments on commit 8b0ccc8

Please sign in to comment.