Skip to content

Commit

Permalink
Change package name to "tinyplot" (#117)
Browse files Browse the repository at this point in the history
* Update function names

* namespace and document

* Update README and tutorial

* typo

* update tests
  • Loading branch information
grantmcdermott authored Feb 6, 2024
1 parent 27c8dcb commit 86dff1c
Show file tree
Hide file tree
Showing 37 changed files with 574 additions and 496 deletions.
18 changes: 9 additions & 9 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: plot2
Package: tinyplot
Type: Package
Title: Lightweight extension of base R plot
Version: 0.0.4
Title: Lightweight Extension of the Base R Graphics System
Version: 0.0.5
Authors@R:
c(
person(
Expand Down Expand Up @@ -31,8 +31,8 @@ Authors@R:
email = "[email protected]"
)
)
Description: Lightweight extension of the base R plot system, with support for
automatic grouping and legend printing, and several other enhancements.
Description: Lightweight extension of the base R graphics system, with support
for automatic legends, facetting, and several other enhancements.
License: GPL (>= 2)
Depends:
R (>= 4.0)
Expand All @@ -54,9 +54,9 @@ Suggests:
Remotes:
etiennebacher/altdoc
Encoding: UTF-8
RoxygenNote: 7.3.0
URL: https://grantmcdermott.com/plot2/,
http://grantmcdermott.com/plot2/
BugReports: https://github.com/grantmcdermott/plot2/issues
RoxygenNote: 7.3.1
URL: https://grantmcdermott.com/tinyplot/,
http://grantmcdermott.com/tinyplot/
BugReports: https://github.com/grantmcdermott/tinyplot/issues
VignetteBuilder: knitr
Roxygen: list(markdown = TRUE)
11 changes: 6 additions & 5 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# Generated by roxygen2: do not edit by hand

S3method(plot2,default)
S3method(plot2,density)
S3method(plot2,formula)
S3method(tinyplot,default)
S3method(tinyplot,density)
S3method(tinyplot,formula)
export(draw_legend)
export(par2)
export(plot2)
export(plt)
export(tinyplot)
export(tpar)
importFrom(grDevices,adjustcolor)
importFrom(grDevices,extendrange)
importFrom(grDevices,hcl.colors)
Expand Down
44 changes: 44 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,49 @@
# News

## 0.0.5

**IMPORTANT BREAKING CHANGE:**

The package has been renamed to **tinyplot**. (#22 @grantmcdermott)

This package renaming also incorporates the following function changes:

- `plot2()` is replaced by `tinyplot()` (or its shorthand alias `plt()`).
- `par2()` is replaced by `tpar()`.

So, where you used to write...

```r
library(plot2)
plot2(Sepal.Length ~ Petal.Length | Species, iris)
```

... you should now write:

```r
library(tinyplot)
tinyplot(Sepal.Length ~ Petal.Length | Species, iris)

# Or, use the equivalent shorthand `plt` alias
plt(Sepal.Length ~ Petal.Length | Species, iris)
```

The package URLs have been updated accordingly:

- GitHub: https://github.com/grantmcdermott/tinyplot
- Website: https://grantmcdermott.com/tinyplot
- R-universe: https://grantmcdermott.r-universe.dev/tinyplot

Many thanks to everyone who provided thoughtful feedback about this prospective
name change, especially @zeileis and @vincentarelbundock for kicking off the
discussion, as well as the 100+ participants who voted in the social media
poll.

For more details about the rational underlying this renaming decision, please
see the following GitHub comment, as well as the discussion that preceded it:
https://github.com/grantmcdermott/plot2/issues/22#issuecomment-1928472754


## 0.0.4

Website:
Expand Down
26 changes: 13 additions & 13 deletions R/draw_legend.R
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
#' @title Calculate placement of legend and and draw it
#' @title Calculate placement of legend and draw it
#'
#' @description Internal function used to calculate the placement of (including
#' outside the plotting area) and drawing of legend.
#'
#' @md
#' @param legend Legend placement keyword or list, passed down from `plot2`.
#' @param legend Legend placement keyword or list, passed down from `tinyplot`.
#' @param legend.args Additional legend arguments to be passed to `legend()`.
#' @param by_dep The (deparsed) "by" grouping variable name.
#' @param lgnd_labs The labels passed to `legend(legend = ...)`.
#' @param type Plotting type(s), passed down from `plot2`.
#' @param pch Plotting character(s), passed down from `plot2`.
#' @param lty Plotting linetype(s), passed down from `plot2`.
#' @param col Plotting colour(s), passed down from `plot2`.
#' @param bg Plotting character background fill colour(s), passed down from `plot2`.
#' @param cex Plotting character expansion(s), passed down from `plot2`.
#' @param type Plotting type(s), passed down from `tinyplot`.
#' @param pch Plotting character(s), passed down from `tinyplot`.
#' @param lty Plotting linetype(s), passed down from `tinyplot`.
#' @param col Plotting colour(s), passed down from `tinyplot`.
#' @param bg Plotting character background fill colour(s), passed down from `tinyplot`.
#' @param cex Plotting character expansion(s), passed down from `tinyplot`.
#' @param lmar Legend margins (in lines). Should be a numeric vector of the form
#' `c(inner, outer)`, where the first number represents the "inner" margin
#' between the legend and the plot, and the second number represents the
#' "outer" margin between the legend and edge of the graphics device. If no
#' explicit value is provided by the user, then reverts back to `par2("lmar")`
#' explicit value is provided by the user, then reverts back to `tpar("lmar")`
#' for which the default values are `c(1.0, 0.1)`.
#' @param has_sub Logical. Does the plot have a sub-caption. Only used if
#' keyword position is "bottom!", in which case we need to bump the legend
Expand Down Expand Up @@ -58,7 +58,7 @@
#'
#' # Note that the inner and outer margin of the legend itself can be set via
#' # the `lmar` argument. (This can also be set globally via
#' # `par2(lmar = c(inner, outer))`.)
#' # `tpar(lmar = c(inner, outer))`.)
#' draw_legend(
#' legend.args = list(title = "Key", bty = "o"),
#' lgnd_labs = c("foo", "bar"),
Expand Down Expand Up @@ -89,7 +89,7 @@ draw_legend = function(
) {

if (is.null(lmar)) {
lmar = par2("lmar")
lmar = tpar("lmar")
} else {
if (!is.numeric(lmar) || length(lmar)!=2) stop ("lmar must be a numeric of length 2.")
}
Expand Down Expand Up @@ -163,11 +163,11 @@ draw_legend = function(
omar = par("mar")
topmar_epsilon = 0.1

# Catch to avoid recursive offsets, e.g. repeated plot2 calls with
# Catch to avoid recursive offsets, e.g. repeated tinyplot calls with
# "bottom!" legend position.

## restore inner margin defaults
## (in case the plot region/margins were affected by the preceding plot2 call)
## (in case the plot region/margins were affected by the preceding tinyplot call)
if (any(ooma != 0)) {
if ( ooma[1] != 0 & omar[1] == par("mgp")[1] + 1*par("cex.lab") ) omar[1] = 5.1
if ( ooma[2] != 0 & omar[2] == par("mgp")[1] + 1*par("cex.lab") ) omar[2] = 4.1
Expand Down
20 changes: 0 additions & 20 deletions R/plot2-package.R

This file was deleted.

22 changes: 22 additions & 0 deletions R/tinyplot-package.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#' \code{tinyplot-package}
#'
#' @title tinyplot: Lightweight extension of the base R graphics system, with
#' support for automatic legends, facetting, and several other enhancements.
#'
#' @description The goal of **tinyplot** is to provides a lightweight extension
#' of the base R graphics system with various convenience features,
#' particularly for representing groups with your data. For example, the core
#' `tinyplot()` function (alias: `plt()` with no vowels) makes it easy to plot
#' different categories of a dataset in a single function call and highlight
#' these categories (groups) using modern colour palettes. Coincident with
#' this grouping support, `tinyplot()` also produces automatic legends with
#' scope for further customization. While the package offers several other
#' enhancements like facets, it tries as far as possible to be a drop-in
#' replacement for the equivalent base plotting calls. Users should generally
#' be able to swap a valid `plot()` call with `tinyplot()` without any changes
#' to the expected output.
#'
#' @docType package
#' @aliases tinyplot-package NULL
#' @keywords internal
"_PACKAGE"
Loading

0 comments on commit 86dff1c

Please sign in to comment.