Skip to content

Commit 84a561d

Browse files
author
maechler
committed
hist(.., log="x") now works without warning
git-svn-id: https://svn.r-project.org/R/trunk@88435 00db46b3-68df-0310-9c12-caf00c1e9a41
1 parent cfa03ce commit 84a561d

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

doc/NEWS.Rd

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,9 @@
231231

232232
\item An initial newline inside an Rd inline \verb{\eqn} no longer
233233
breaks the paragraph in plain-text help (\code{tools::Rd2txt}).
234+
235+
\item \code{hist(*, log = "x")} now works without a warning, thanks
236+
to \I{Martin Smith}'s \PR{18921}.
234237
}
235238
}
236239
}

src/library/graphics/R/hist.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# File src/library/graphics/R/hist.R
22
# Part of the R package, https://www.R-project.org
33
#
4-
# Copyright (C) 1995-2021 The R Core Team
4+
# Copyright (C) 1995-2025 The R Core Team
55
#
66
# This program is free software; you can redistribute it and/or modify
77
# it under the terms of the GNU General Public License as published by
@@ -169,7 +169,7 @@ plot.histogram <-
169169
main = paste("Histogram of", paste(x$xname, collapse="\n")),
170170
sub = NULL,
171171
xlab = x$xname, ylab,
172-
xlim = range(x$breaks), ylim = NULL,
172+
xlim = range(x$breaks), ylim = NULL, log = "",
173173
axes = TRUE, labels = FALSE, add = FALSE, ann = TRUE, ...)
174174
{
175175
equidist <-
@@ -189,7 +189,7 @@ plot.histogram <-
189189
if (missing(ylab))
190190
ylab <- if (!freq) "Density" else "Frequency"
191191
plot.new()
192-
plot.window(xlim, ylim, "", ...) #-> ylim's default from 'y'
192+
plot.window(xlim, ylim, log, ...) #-> ylim's default from 'y'
193193
if(ann) title(main = main, sub = sub, xlab = xlab, ylab = ylab, ...)
194194
if(axes) {
195195
axis(1, ...)

src/library/graphics/man/hist.Rd

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
% File src/library/graphics/man/hist.Rd
22
% Part of the R package, https://www.R-project.org
3-
% Copyright 1995-2022 R Core Team
3+
% Copyright 1995-2025 R Core Team
44
% Distributed under GPL 2 or later
55

66
\name{hist}
@@ -70,8 +70,8 @@ hist(x, \dots)
7070
\item{xlim, ylim}{the range of x and y values with sensible defaults.
7171
Note that \code{xlim} is \emph{not} used to define the histogram (breaks),
7272
but only for plotting (when \code{plot = TRUE}).}
73-
\item{axes}{logical. If \code{TRUE} (default), axes are draw if the
74-
plot is drawn.}
73+
\item{log}{a string, by default \code{""}, otherwise typically \code{"x"}.}
74+
\item{axes}{logical. If \code{TRUE} (default), axes are drawn when the plot is.}
7575
\item{plot}{logical. If \code{TRUE} (default), a histogram is
7676
plotted, otherwise a list of breaks and counts is returned. In the
7777
latter case, a warning is used if (typically graphical) arguments

tests/reg-tests-1e.R

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2046,6 +2046,13 @@ fixInNamespace("toRd.default", "tools", editor = function (...) omethod)
20462046
assertValueIs("1")
20472047

20482048

2049+
## No warnings for hist(.., log="x") -- PR#18921
2050+
op <- options(warn = 2)
2051+
hist(1:100, breaks = 2^(0:8), log = "x")
2052+
options(op)
2053+
## used to signal 3 warnings
2054+
2055+
20492056

20502057
## keep at end
20512058
rbind(last = proc.time() - .pt,

0 commit comments

Comments
 (0)