Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit05f519b

Browse files
authored
breaks_pretty() will return zero-range limit (#455)
1 parent5a3ddee commit05f519b

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

‎NEWS.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#scales (development version)
22

3+
*`breaks_pretty()` will return the input limit when it has no range (#446)
34
*`transform_exp()` now has more sensible breaks, available in`breaks_exp()`
45
(@teunbrand,#405).
56
* The scales package now keeps track of known palettes. These can be retrieved

‎R/breaks.R‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@ breaks_pretty <- function(n = 5, ...) {
122122
force_all(n,...)
123123
n_default<-n
124124
function(x,n=n_default) {
125+
if (zero_range(as.numeric(x))) {
126+
return(x[1])
127+
}
125128
breaks<- pretty(x,n,...)
126129
names(breaks)<- attr(breaks,"labels")
127130
breaks

‎tests/testthat/test-breaks.R‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,11 @@ test_that("breaks_pretty() arguments are forcely evaluated on each call #81", {
3131
expect_equal(subfun2(1),subfuns[[2]](1))
3232
})
3333

34-
test_that("exponential breaks give sensible values", {
34+
test_that("breaks_pretty() returns input when given zero-width range (#446)", {
35+
expect_equal(breaks_pretty()(c(1,1)),1)
36+
})
3537

38+
test_that("exponential breaks give sensible values", {
3639
x<- breaks_exp()(c(0,2))
3740
expect_equal(x, c(0,0.5,1,1.5,2))
3841

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp