Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contour breaks function works in absence of bins and binwidth #5703

Merged
merged 4 commits into from
Mar 18, 2024
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
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@

# ggplot2 (development version)

* When passing a function to `stat_contour(breaks)`, that function is used to
calculate the breaks even if `bins` and `binwidth` are missing
(@teunbrand, #5686).
* `geom_step()` now supports `lineend`, `linejoin` and `linemitre` parameters
(@teunbrand, #5705).
* Fixed performance loss when the `.data` pronoun is used in `aes()` (#5730).
Expand Down
8 changes: 3 additions & 5 deletions R/stat-contour.R
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,8 @@ contour_breaks <- function(z_range, bins = NULL, binwidth = NULL, breaks = NULL)
breaks_fun <- fullseq
if (is.function(breaks)) {
breaks_fun <- breaks
}

# If no parameters set, use pretty bins
if (is.null(bins) && is.null(binwidth)) {
} else if (is.null(bins) && is.null(binwidth)) {
# If no parameters set, use pretty bins
breaks <- pretty(z_range, 10)
return(breaks)
}
Expand Down Expand Up @@ -206,7 +204,7 @@ contour_breaks <- function(z_range, bins = NULL, binwidth = NULL, breaks = NULL)
}

# if we haven't returned yet, compute breaks from binwidth
breaks_fun(z_range, binwidth)
breaks_fun(z_range, binwidth %||% (diff(z_range) / 10))
}

#' Compute isoband objects
Expand Down
Loading