Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add global option to specify default dpi #21

Merged
merged 13 commits into from
Feb 13, 2021
6 changes: 5 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ language: r
## no tests, coverage
## check as CRAN

before_install:
- sudo apt-get update -y
- sudo apt-get -y install libglu1-mesa-dev libharfbuzz-dev libfribidi-dev

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

## [0.2.2] - 2021-02-10
* Add global option for `dpi` using `options(ggrastr.default.dpi=N)`. PR found here: https://github.com/VPetukhov/ggrastr/pull/21
* Vignettes edited accordingly
* Use both html and markdown for vignettes, link to README


## [0.2.1] - 2020-09-14
* Changes to be in sync with ggrastr version 0.2.1 on CRAN: https://cran.rstudio.com/src/contrib/ggrastr_0.2.1.tar.gz
* Aesthetic revisions to the github README
* Otherwise, this version mirrors https://github.com/VPetukhov/ggrastr/releases/tag/v0.2.0


## [0.2.0] - 2020-08
* Refactor code to use rasterise()
* Added `geom_violin_rast()` as a feature request
Expand Down
56 changes: 28 additions & 28 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
Package: ggrastr
Type: Package
Title: Raster Layers for 'ggplot2'
Version: 0.2.2
Authors@R: c(person("Viktor", "Petukhov", email = "viktor.s.petukhov@ya.ru", role = c("aut", "cph")), person("Teun", "van den Brand", email = "t.vd.brand@nki.nl", role=c("aut")), person("Evan", "Biederstedt", email = "evan.biederstedt@gmail.com", 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,
grid,
ragg,
png
Depends:
R (>= 3.2.2)
RoxygenNote: 7.1.1
Suggests:
rmarkdown,
knitr
VignetteBuilder: knitr
URL: https://github.com/VPetukhov/ggrastr
BugReports: https://github.com/VPetukhov/ggrastr/issues
NeedsCompilation: no
Author: Viktor Petukhov [aut, cph], Teun van den Brand [aut], Evan Biederstedt [cre, aut]
Maintainer: Evan Biederstedt <evan.biederstedt@gmail.com>
Package: ggrastr
Type: Package
Title: Raster Layers for 'ggplot2'
Version: 0.2.2
Authors@R: c(person("Viktor", "Petukhov", email = "viktor.s.petukhov@ya.ru", role = c("aut", "cph")), person("Teun", "van den Brand", email = "t.vd.brand@nki.nl", role=c("aut")), person("Evan", "Biederstedt", email = "evan.biederstedt@gmail.com", 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,
grid,
ragg,
png
Depends:
R (>= 3.2.2)
RoxygenNote: 7.1.1
Suggests:
rmarkdown,
knitr
VignetteBuilder: knitr
URL: https://github.com/VPetukhov/ggrastr
BugReports: https://github.com/VPetukhov/ggrastr/issues
NeedsCompilation: no
Author: Viktor Petukhov [aut, cph], Teun van den Brand [aut], Evan Biederstedt [cre, aut]
Maintainer: Evan Biederstedt <evan.biederstedt@gmail.com>
4 changes: 2 additions & 2 deletions R/geom-beeswarm-rast.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#' @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 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)
#' @param raster.dpi An integer of length one setting the desired resolution in dots per inch. (default=300)
#' @param dev A character specifying a device. Can be one of: \code{"cairo"}, \code{"ragg"} or \code{"ragg_png"}. (default="cairo")
Expand All @@ -19,7 +19,7 @@
#' ggplot(mtcars) + geom_beeswarm_rast(aes(x = factor(cyl), y = mpg), raster.dpi = 600, cex = 1.5)
#'
#' @export
geom_beeswarm_rast <- function(..., priority= c("ascending", "descending", "density", "random", "none"), cex = 1, groupOnX = NULL, dodge.width = 0, raster.dpi = 300, dev="cairo") {
geom_beeswarm_rast <- function(..., priority= c("ascending", "descending", "density", "random", "none"), cex = 1, groupOnX = NULL, dodge.width = 0, raster.dpi = getOption("ggrastr.default.dpi", 300), dev="cairo") {
rasterise(ggbeeswarm::geom_beeswarm(..., priority=priority, cex=cex, groupOnX=groupOnX, dodge.width=dodge.width), dpi=raster.dpi, dev=dev)
}

8 changes: 4 additions & 4 deletions R/geom-boxplot-jitter.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ DrawGeomBoxplotJitter <- function(data, panel_params, coord, dev="cairo", ...,
outlier.size = 1.5,
outlier.stroke = 0.5,
outlier.alpha = NULL,
raster=FALSE, raster.dpi=300,
raster=FALSE, raster.dpi=getOption("ggrastr.default.dpi", 300),
raster.width=NULL, raster.height=NULL
) {
boxplot_grob <- ggplot2::GeomBoxplot$draw_group(data, panel_params, coord, ...)
Expand Down Expand Up @@ -76,7 +76,7 @@ GeomBoxplotJitter <- ggplot2::ggproto("GeomBoxplotJitter",
#' @param outlier.jitter.height Amount of horizontal jitter. The jitter is added in both positive and negative directions,
#' so the total spread is twice the value specified here (default=0)
#' @param raster.dpi Resolution of the rastered image (default=300). Ignored if \code{raster == FALSE}.
#' @param dev A character specifying a device (default="cairo"). Can be one of: \code{"cairo"}, \code{"ragg"} or \code{"ragg_png"}.
#' @param dev A character specifying a device (default="cairo"). Can be one of: \code{"cairo"}, \code{"ragg"} or \code{"ragg_png"}.
#' @return geom_boxplot plot with rasterized layer
#'
#' @examples
Expand All @@ -94,7 +94,7 @@ geom_boxplot_jitter <- function(mapping = NULL, data = NULL, dev = "cairo",
inherit.aes = TRUE, ...,
outlier.jitter.width=NULL,
outlier.jitter.height=0,
raster.dpi=300
raster.dpi=getOption("ggrastr.default.dpi", 300)
) {
ggplot2::layer(
geom = GeomBoxplotJitter, mapping = mapping, data = data, stat = stat,
Expand All @@ -103,4 +103,4 @@ geom_boxplot_jitter <- function(mapping = NULL, data = NULL, dev = "cairo",
outlier.jitter.width=outlier.jitter.width,
outlier.jitter.height=outlier.jitter.height,
raster.dpi=raster.dpi, dev=dev, ...))
}
}
4 changes: 2 additions & 2 deletions R/geom-jitter-rast.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
#' ggplot(mpg) + geom_jitter_rast(aes(x = factor(cyl), y = hwy), raster.dpi = 600)
#'
#' @export
geom_jitter_rast <- function(..., raster.dpi = 300, dev="cairo"){
geom_jitter_rast <- function(..., raster.dpi = getOption("ggrastr.default.dpi", 300), dev="cairo"){
rasterise(geom_jitter(...), dpi=raster.dpi, dev=dev)
}
}
2 changes: 1 addition & 1 deletion R/geom-point-rast.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
#' ggplot() + geom_point_rast(aes(x=rnorm(1000), y=rnorm(1000)), raster.dpi=600)
#'
#' @export
geom_point_rast <- function(..., raster.dpi=300, dev="cairo") {
geom_point_rast <- function(..., raster.dpi=getOption("ggrastr.default.dpi", 300), dev="cairo") {
rasterise(geom_point(...), dpi=raster.dpi, dev=dev)
}
2 changes: 1 addition & 1 deletion R/geom-quasirandom-rast.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
#' ggplot(mtcars) + geom_quasirandom_rast(aes(x = factor(cyl), y = mpg), raster.dpi = 600)
#'
#' @export
geom_quasirandom_rast <- function(..., width = NULL, varwidth = FALSE, bandwidth = 0.5, nbins = NULL, method = "quasirandom", groupOnX = NULL, dodge.width = 0, raster.dpi = 300, dev="cairo") {
geom_quasirandom_rast <- function(..., width = NULL, varwidth = FALSE, bandwidth = 0.5, nbins = NULL, method = "quasirandom", groupOnX = NULL, dodge.width = 0, raster.dpi = getOption("ggrastr.default.dpi", 300), dev="cairo") {
rasterise(ggbeeswarm::geom_quasirandom(..., width = width, varwidth = varwidth, bandwidth = bandwidth, nbins = nbins, method = method, groupOnX = groupOnX, dodge.width = dodge.width), dpi=raster.dpi, dev=dev)
}
4 changes: 2 additions & 2 deletions R/geom-tile-rast.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
#' ggplot(coords) + geom_tile_rast(aes(x=Var1, y=Var2, fill=Value))
#'
#' @export
geom_tile_rast <- function(..., raster.dpi=300, dev="cairo") {
geom_tile_rast <- function(..., raster.dpi=getOption("ggrastr.default.dpi", 300), dev="cairo") {
rasterise(geom_tile(...), dpi=raster.dpi, dev=dev)
}
}
4 changes: 2 additions & 2 deletions R/geom-violin-rast.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
#' ggplot(mpg) + geom_violin_rast(aes(x = factor(cyl), y = hwy), raster.dpi = 600)
#'
#' @export
geom_violin_rast = function(..., raster.dpi=300, dev="cairo"){
geom_violin_rast = function(..., raster.dpi=getOption("ggrastr.default.dpi", 300), dev="cairo"){
rasterise(geom_violin(...), dpi=raster.dpi, dev=dev)
}
}
Loading