Skip to content

Commit 8d8b58e

Browse files
author
maechler
committed
improve ex.: customized axis() inspired by Martin Smith` PR#18108#c6
git-svn-id: https://svn.r-project.org/R/trunk@88436 00db46b3-68df-0310-9c12-caf00c1e9a41
1 parent 84a561d commit 8d8b58e

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

src/library/graphics/man/barplot.Rd

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

66
\name{barplot}
@@ -184,12 +184,14 @@ par(op)
184184
# Default method
185185
require(grDevices) # for colours
186186
tN <- table(Ni <- stats::rpois(100, lambda = 5))
187+
## barplot() returns x-locations:
187188
r <- barplot(tN, col = rainbow(20))
188-
#- type = "h" plotting *is* 'bar'plot
189-
lines(r, tN, type = "h", col = "red", lwd = 2)
189+
lines(r, tN, type = "h", col = 2, lwd = 7) # type "h" plot *is* 'bar'plot
190190

191+
## draw axis separately using x-locations from barplot():
191192
barplot(tN, space = 1.5, axisnames = FALSE,
192-
sub = "barplot(..., space= 1.5, axisnames = FALSE)")
193+
sub = "barplot(..., space= 1.5, axisnames = FALSE)"
194+
) |> axis(1, at = _, labels = paste("# :", tN), cex.axis = 3/4)
193195

194196
barplot(VADeaths, plot = FALSE)
195197
barplot(VADeaths, plot = FALSE, beside = TRUE)

tests/Examples/graphics-Ex.Rout.save

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
R Under development (unstable) (2025-02-17 r87727) -- "Unsuffered Consequences"
2+
R Under development (unstable) (2025-07-21 r88434) -- "Unsuffered Consequences"
33
Copyright (C) 2025 The R Foundation for Statistical Computing
44
Platform: x86_64-pc-linux-gnu
55

@@ -383,12 +383,14 @@ Survived 1st 2nd 3rd Crew
383383
> # Default method
384384
> require(grDevices) # for colours
385385
> tN <- table(Ni <- stats::rpois(100, lambda = 5))
386+
> ## barplot() returns x-locations:
386387
> r <- barplot(tN, col = rainbow(20))
387-
> #- type = "h" plotting *is* 'bar'plot
388-
> lines(r, tN, type = "h", col = "red", lwd = 2)
388+
> lines(r, tN, type = "h", col = 2, lwd = 7) # type "h" plot *is* 'bar'plot
389389
>
390+
> ## draw axis separately using x-locations from barplot():
390391
> barplot(tN, space = 1.5, axisnames = FALSE,
391-
+ sub = "barplot(..., space= 1.5, axisnames = FALSE)")
392+
+ sub = "barplot(..., space= 1.5, axisnames = FALSE)"
393+
+ ) |> axis(1, at = _, labels = paste("# :", tN), cex.axis = 3/4)
392394
>
393395
> barplot(VADeaths, plot = FALSE)
394396
[1] 0.7 1.9 3.1 4.3

0 commit comments

Comments
 (0)