Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,10 @@ where the formatting is also better._
`pch = "."`. (#338 @grantmcdermott)
- Line plots (`type_lines()`/`"l"`) now pass on the `bg` argument to the
drawing function. Thanks to @wviechtb for report in #355 (@zeileis).
- Fixed dynamic LHS margin spacing for flipped `"boxplot"` and `"jitter"` types.
Thanks to @eddelbuettel for the report in #357 (@grantmcdermott).
- Fixed dynamic y-axis margin spacing for flipped `"boxplot"` and `"jitter"`
types. Thanks to @eddelbuettel for the report in #357 (@grantmcdermott).
- Fixed dynamic x-axis margin spacing for perpendicular (vertical) label text,
i.e. cases where `las = 2` or `las = 3`. #369 (@grantmcdermott).

### Internals:

Expand Down
24 changes: 14 additions & 10 deletions R/facet.R
Original file line number Diff line number Diff line change
Expand Up @@ -199,28 +199,32 @@ draw_facet_window = function(grid, ...) {
omar = omar + c(0, whtsbp, 0, 0) * cex_fct_adj
fmar[2] = fmar[2] + whtsbp * cex_fct_adj
}
# Extra reduction if no plot frame to reduce whitespace
if (isFALSE(frame.plot) && !isTRUE(facet.args[["free"]])) {
fmar[2] = fmar[2] - (whtsbp * cex_fct_adj)
}
}
if (par("las") %in% 2:3) {
# extra whitespace bump on the x axis
# xaxlabs = axTicks(1)
xaxlabs = axisTicks(usr = extendrange(xlim, f = 0.04), log = par("xlog"))
xaxlabs = if (is.null(xlabs)) axisTicks(usr = extendrange(xlim, f = 0.04), log = par("xlog")) else
if (!is.null(names(xlabs))) names(xlabs) else xlabs
if (!is.null(xaxl)) xaxlabs = tinylabel(xaxlabs, xaxl)
whtsbp = grconvertY(max(strwidth(xaxlabs, "figure")), from = "nfc", to = "lines") - 1
# whtsbp = grconvertY(max(strwidth(xaxlabs, "figure")), from = "nfc", to = "lines") - grconvertY(0, from = "nfc", to = "lines") - 1
whtsbp = grconvertX(max(strwidth(xaxlabs, "figure")), from = "nfc", to = "lines") - 1
if (whtsbp > 0) {
omar = omar + c(whtsbp, 0, 0, 0) * cex_fct_adj
fmar[1] = fmar[1] + whtsbp * cex_fct_adj
}
# Extra reduction if no plot frame to reduce whitespace
if (isFALSE(frame.plot) && !isTRUE(facet.args[["free"]])) {
fmar[1] = fmar[1] - (whtsbp * cex_fct_adj)
}
}
# FIXME: Is this causing issues for lhs legends with facet_grid?
# catch for missing rhs legend
if (isTRUE(attr(facet, "facet_grid")) && !has_legend) {
omar[4] = omar[4] + 1
}
# Extra reduction if no plot frame to reduce whitespace
if (isFALSE(frame.plot) && !isTRUE(facet.args[["free"]])) {
fmar[2] = fmar[2] - (whtsbp * cex_fct_adj)
}
}

# Now we set the margins. The trick here is that we simultaneously adjust
Expand Down Expand Up @@ -271,10 +275,10 @@ draw_facet_window = function(grid, ...) {
if (par("las") %in% 2:3) {
# extra whitespace bump on the x axis
# xaxl = axTicks(1)
xaxlabs = axisTicks(usr = extendrange(ylim, f = 0.04), log = par("xlog"))
xaxlabs = if (is.null(xlabs)) axisTicks(usr = extendrange(xlim, f = 0.04), log = par("xlog")) else
if (!is.null(names(xlabs))) names(xlabs) else xlabs
if (!is.null(xaxl)) xaxlabs = tinylabel(xaxlabs, xaxl)
whtsbp = grconvertY(max(strwidth(xaxlabs, "figure")), from = "nfc", to = "lines") - 1
# whtsbp = grconvertY(max(strwidth(xaxlabs, "figure")), from = "nfc", to = "lines") - grconvertY(0, from = "nfc", to = "lines") - 1
whtsbp = grconvertX(max(strwidth(xaxlabs, "figure")), from = "nfc", to = "lines") - 1
if (whtsbp > 0) {
omar[1] = omar[1] + whtsbp
}
Expand Down
Loading