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
8 changes: 8 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ where the formatting is also better._

## 0.1.0.99 (dev version)

New features:

- Support for `type = "n"` (empty) plots. (#157 @grantmcdermott)

Misc:

- Various documentation improvements.

## 0.1.0

Our first CRAN submission! This v0.1.0 release includes the following new
Expand Down
3 changes: 3 additions & 0 deletions R/draw_legend.R
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,9 @@ draw_legend = function(
if (is.null(legend_args[["y.intersp"]])) legend_args[["y.intersp"]] = 1.25
if (is.null(legend_args[["seg.len"]])) legend_args[["seg.len"]] = 1.25
}
if (type == "n" && isFALSE(gradient)) {
if (is.null(legend_args[["pch"]])) legend_args[["pch"]] = par("pch")
}


if (is.null(legend_args[["legend"]])) {
Expand Down
8 changes: 5 additions & 3 deletions R/tinyplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@
#' @param type character string giving the type of plot desired. Options are:
#' - The same set of 1-character values supported by plot: "p" for points, "l"
#' for lines, "b" for both points and lines, "c" for empty points joined by
#' lines, "o" for overplotted points and lines, "s" and "S" for stair steps
#' and "h" for histogram-like vertical lines. "n" does not produce
#' any points or lines.
#' lines, "o" for overplotted points and lines, "s" and "S" for stair steps,
#' and "h" for histogram-like vertical lines. Specifying "n" produces an empty
#' plot over the extent of the data, but with no internal elements.
#' - Additional tinyplot types: "density" for densities, "polygon" for
#' polygons, "pointrange" or "errorbar" for segment intervals, and "polygon",
#' "ribbon" or "area" for polygon intervals (where area plots are a special
Expand Down Expand Up @@ -1372,6 +1372,8 @@ tinyplot.default = function(
lty = ilty,
lwd = ilwd
)
} else if (type == "n") {
# Blank plot
} else {
stop("`type` argument not supported.", call. = FALSE)
}
Expand Down
60 changes: 60 additions & 0 deletions inst/tinytest/_tinysnapshot/type_n.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
76 changes: 76 additions & 0 deletions inst/tinytest/_tinysnapshot/type_n_by.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 12 additions & 3 deletions inst/tinytest/test-misc.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
source("helpers.R")
using("tinysnapshot")

# empty plot(s)
f = function () {
tinyplot(Sepal.Length ~ Petal.Length, data = iris, type = "n")
}
expect_snapshot_plot(f, label = "type_n")
# empty plot(s)
f = function () {
tinyplot(Sepal.Length ~ Petal.Length | Species, data = iris, type = "n")
}
expect_snapshot_plot(f, label = "type_n_by")

# log axes
f = function() {
op = tpar(mfrow = c(1, 2))
plot(Temp ~ Day, data = airquality, log = "x")
Expand Down Expand Up @@ -33,9 +45,6 @@ f = function() {
}
expect_snapshot_plot(f, label = "arg_log_yx")

## https://bugs.r-project.org/show_bug.cgi?id=18337
# exit_if_not(getRversion() >= "4.4.0")

f = function() {
op = tpar(mfrow = c(1, 1))
m = transform(mtcars, cyl = factor(cyl))
Expand Down
6 changes: 3 additions & 3 deletions man/tinyplot.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.