Skip to content

Commit

Permalink
Merge pull request #11 from evanbiederstedt/cran_review_fix
Browse files Browse the repository at this point in the history
CRAN version 0.1.8
  • Loading branch information
VPetukhov authored Jun 19, 2020
2 parents 2e9a3a2 + 5da02c7 commit f90af5c
Show file tree
Hide file tree
Showing 25 changed files with 304 additions and 546 deletions.
3 changes: 3 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
^.*\.Rproj$
^\.Rproj\.user$
.travis.yml
CHANGELOG.md
^LICENSE\.md$
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
.Rhistory
.RData
.Ruserdata
ggrastr*.tar.gz
12 changes: 12 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
language: r

## minimal travis config
## https://docs.travis-ci.com/user/languages/r/
## https://towardsdatascience.com/travis-ci-for-r-advanced-guide-719cb2d9e0e5

## no tests, coverage
## check as CRAN

script:
- R CMD build . --compact-vignettes=gs+qpdf
- R CMD check *tar.gz --as-cran
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# Changelog

## [0.1.8] - 2020-06-19
* Revisions for first version on CRAN.
* Documentation revisions, changes to the vignettes

## [0.1.7] - 2018-12-02
### Fixed
* All pararmeters `width`, `hight` and `dpi` renamed to `raster.width`, `raster.hight` and `raster.dpi` correspondingly to avoid name conflicts.
Expand Down
23 changes: 14 additions & 9 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
Package: ggrastr
Type: Package
Title: Raster layers for ggplot2
Version: 0.1.7
Authors@R: c(person("Viktor", "Petukhov", email = "[email protected]", role = c("cre", "aut")))
Description: Raster geoms for ggplot2
License: MIT
Title: Raster Layers for 'ggplot2'
Version: 0.1.8
Authors@R: c(person("Viktor", "Petukhov", email = "[email protected]", role = c("aut", "cph")), person("Evan", "Biederstedt", email = "[email protected]", role=c("cre", "aut")))
Description: Provides a set of geoms to rasterize only specific layers of the plot while simultaneously keeping all labels and text in vector format. This allows users to keep plots within the reasonable size limit without loosing vector properties of the scale-sensitive information.
License: MIT + file LICENSE
Encoding: UTF-8
LazyData: true
Imports:
ggplot2 (>= 2.1.0),
Cairo (>= 1.5.9),
ggbeeswarm
Depends:
R (>= 3.2.2)
RoxygenNote: 6.1.0
RoxygenNote: 7.1.0
Suggests:
ggbeeswarm,
knitr,
rmarkdown
rmarkdown,
knitr
VignetteBuilder: knitr
URL: https://github.com/VPetukhov/ggrastr
BugReports: https://github.com/VPetukhov/ggrastr/issues
NeedsCompilation: no
Author: Viktor Petukhov [aut, cph], Evan Biederstedt [cre, aut]
Maintainer: Evan Biederstedt <[email protected]>
23 changes: 2 additions & 21 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,21 +1,2 @@
MIT License

Copyright (c) 2017 Viktor Petukhov

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
YEAR: 2020
COPYRIGHT HOLDER: Viktor Petukhov <[email protected]>
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2017 Viktor Petukhov

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
6 changes: 6 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,9 @@ export(geom_point_rast)
export(geom_quasirandom_rast)
export(geom_tile_rast)
export(theme_pdf)
import(ggbeeswarm)
import(ggplot2)
importFrom(grDevices,dev.cur)
importFrom(grDevices,dev.off)
importFrom(grDevices,dev.set)
importFrom(graphics,par)
18 changes: 11 additions & 7 deletions R/geom-beeswarm-rast.R
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
#' This geom is similar to \code{\link[ggbeeswarm]{geom_beeswarm}}, but creates a raster layer
#'
#' @inheritParams geom_point_rast
#' @inheritParams ggbeeswarm::position_beeswarm
#' @inheritSection ggplot2::geom_point Aesthetics
#'
#' @import ggplot2
#' @import ggbeeswarm
#' @param priority Method used to perform point layout (see ggbeeswarm::position_beeswarm)
#' @param cex Scaling for adjusting point spacing (see ggbeeswarm::position_beeswarm)
#' @param groupOnX Should jitter be added to the x axis if TRUE or y axis if FALSE (the default NULL causes the function to guess which axis is the categorical one based on the number of unique entries in each) Refer to see ggbeeswarm::position_beeswarm
#' @param dodge.width Amount by which points from different aesthetic groups will be dodged. This requires that one of the aesthetics is a factor. (see ggbeeswarm::position_beeswarm)
#' @return geom_beeswarm plot with rasterized layer
#'
#' @examples
#' library(ggplot2)
#' library(ggrastr)
#'
#' ggplot(mtcars) + geom_beeswarm_rast(aes(x = factor(cyl), y = mpg), raster.dpi = 600, cex = 1.5)
#'

#' @export
geom_beeswarm_rast <- function(
mapping = NULL,
Expand All @@ -25,10 +33,6 @@ geom_beeswarm_rast <- function(
raster.width=NULL, raster.height=NULL, raster.dpi=300
) {

if (!requireNamespace('ggbeeswarm', quietly = T)) {
stop('Install \"ggbeeswarm\" to use this function', call. = F)
}

position <- ggbeeswarm::position_beeswarm(priority = priority, cex = cex,
groupOnX = groupOnX, dodge.width = dodge.width)

Expand Down
8 changes: 7 additions & 1 deletion R/geom-boxplot-jitter.R
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,15 @@ GeomBoxplotJitter <- ggplot2::ggproto("GeomBoxplotJitter",
#' @param raster.dpi Resolution of the rastered image. Ignored if \code{raster == FALSE}.
#' @param raster.width Width of the result image (in inches). Default: deterined by the current device parameters. Ignored if \code{raster == FALSE}.
#' @param raster.height Height of the result image (in inches). Default: deterined by the current device parameters. Ignored if \code{raster == FALSE}.
#' @return geom_boxplot plot with rasterized layer
#'
#' @examples
#' ggplot() + geom_boxplot_jitter(aes(y=rt(1000, df=3), x=as.factor(1:1000 %% 2)), outlier.jitter.width = 0.1, raster = T)
#' library(ggplot2)
#' library(ggrastr)
#'
#' yvalues = rt(1000, df=3)
#' xvalues = as.factor(1:1000 %% 2)
#' ggplot() + geom_boxplot_jitter(aes(y=yvalues, x=xvalues), outlier.jitter.width = 0.1, raster = TRUE)
#'
#' @export
geom_boxplot_jitter <- function(mapping = NULL, data = NULL,
Expand Down
7 changes: 7 additions & 0 deletions R/geom-point-rast.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#' @importFrom grDevices dev.cur dev.off dev.set
#' @importFrom graphics par
DrawGeomPointRast <- function(data, panel_params, coord, na.rm = FALSE, raster.width=NULL, raster.height=NULL, raster.dpi=300) {
if (is.null(raster.width)) {
raster.width <- par('fin')[1]
Expand Down Expand Up @@ -36,11 +38,16 @@ GeomPointRast <- ggplot2::ggproto(
#' @inheritParams ggplot2::geom_point
#' @inheritSection ggplot2::geom_point Aesthetics
#'
#' @import ggplot2
#' @param raster.width Width of the result image (in inches). Default: deterined by the current device parameters.
#' @param raster.height Height of the result image (in inches). Default: deterined by the current device parameters.
#' @param raster.dpi Resolution of the result image.
#' @return geom_point plot with rasterized layer
#'
#' @examples
#' library(ggplot2)
#' library(ggrastr)
#'
#' ggplot() + geom_point_rast(aes(x=rnorm(1000), y=rnorm(1000)), raster.dpi=600)
#'
#' @export
Expand Down
21 changes: 10 additions & 11 deletions R/geom-quasirandom-rast.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,34 @@
#' @inheritParams geom_point_rast
#' @inheritParams ggbeeswarm::position_quasirandom
#' @inheritSection ggplot2::geom_point Aesthetics
#' @return geom_quasirandom plot with rasterized layer
#'
#' @examples
#' library(ggplot2)
#' library(ggrastr)
#'
#' ggplot(mtcars) + geom_quasirandom_rast(aes(x = factor(cyl), y = mpg), raster.dpi = 600)
#'

#' @export
geom_quasirandom_rast <- function(
mapping = NULL,
data = NULL,
stat = 'identity',
position = 'quasirandom',
width=NULL,
width = NULL,
varwidth = FALSE,
bandwidth=.5,
nbins=NULL,
bandwidth = 0.5,
nbins = NULL,
method = 'quasirandom',
groupOnX=NULL,
dodge.width=0,
groupOnX = NULL,
dodge.width = 0,
...,
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE,
raster.width=NULL, raster.height=NULL, raster.dpi=300
raster.width = NULL, raster.height = NULL, raster.dpi = 300
) {

if (!requireNamespace('ggbeeswarm', quietly = T)) {
stop('Install \"ggbeeswarm\" to use this function', call. = F)
}

position <- ggbeeswarm::position_quasirandom(width = width, varwidth = varwidth, bandwidth = bandwidth, nbins = nbins,
method = method, groupOnX = groupOnX, dodge.width = dodge.width)

Expand Down
4 changes: 4 additions & 0 deletions R/geom-tile-rast.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,12 @@ GeomTileRast <- ggplot2::ggproto(
#' @param raster.width Width of the result image (in inches). Default: deterined by the current device parameters.
#' @param raster.height Height of the result image (in inches). Default: deterined by the current device parameters.
#' @param raster.dpi Resolution of the result image.
#' @return geom_tile plot with rasterized layer
#'
#' @examples
#' library(ggplot2)
#' library(ggrastr)
#'
#' coords <- expand.grid(1:100, 1:100)
#' coords$Value <- 1 / apply(as.matrix(coords), 1, function(x) sum((x - c(50, 50))^2)^0.01)
#' ggplot(coords) + geom_tile_rast(aes(x=Var1, y=Var2, fill=Value))
Expand Down
15 changes: 11 additions & 4 deletions R/utils.R
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
#' Pretty theme
#'
#' @param show.ticks Show x- and y- ticks.
#' @param show.ticks Show x- and y-ticks.
#' @param legend.pos Vector with x and y position of the legend.
#' @return ggplot2 with plot ticks and positioned legend
#'
#' @examples
#' ggplot() + geom_point(aes(x=rnorm(1000), y=rnorm(1000), color=(1:1000 / 1000))) + theme_pdf(F, legend.pos=c(1, 1))
#' library(ggplot2)
#' library(ggrastr)
#'
#' data = rnorm(100)
#' colors = (1:100/100)
#' ggplot() + geom_point(aes(x=data, y=data, color=colors)) + theme_pdf(FALSE, legend.pos=c(1, 1))
#'
#' @export
theme_pdf <- function(show.ticks=T, legend.pos=NULL) {
r <- ggplot2::theme(axis.line = ggplot2::element_line(size=.7, color = "black"),
theme_pdf <- function(show.ticks=TRUE, legend.pos=NULL) {
r <- ggplot2::theme(axis.line = ggplot2::element_line(size=0.7, color = "black"),
axis.text=ggplot2::element_text(size=12),
axis.title.x=ggplot2::element_text(margin=ggplot2::margin(t=3, unit='pt')),
axis.title.y=ggplot2::element_text(margin=ggplot2::margin(r=3, unit='pt')),
Expand All @@ -31,5 +37,6 @@ theme_pdf <- function(show.ticks=T, legend.pos=NULL) {
if (!is.null(legend.pos)) {
r <- r + ggplot2::theme(legend.position=legend.pos, legend.justification=legend.pos)
}

return(r)
}
75 changes: 0 additions & 75 deletions inst/doc/Raster_geoms.R

This file was deleted.

Loading

0 comments on commit f90af5c

Please sign in to comment.