Skip to content

Add support for native rasters to annotation_raster() #3388 #3794

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

Merged
merged 1 commit into from
Feb 4, 2020
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
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# ggplot2 (development version)

* `annotation_raster()` adds support for native rasters. For large rasters,
native rasters render significantly faster than arrays (@kent37, #3388)

# ggplot2 3.3.0

* Fix a bug in `geom_raster()` that squeezed the image when it went outside
Expand Down
5 changes: 3 additions & 2 deletions R/annotation-raster.r
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ NULL
#' of the raster, and the raster must already have its own colours). This
#' is useful for adding bitmap images.
#'
#' @param raster raster object to display
#' @param raster raster object to display, may be an `array` or a `nativeRaster`
#' @param xmin,xmax x location (in data coordinates) giving horizontal
#' location of raster
#' @param ymin,ymax y location (in data coordinates) giving vertical
Expand Down Expand Up @@ -39,7 +39,8 @@ NULL
#' geom_point()
annotation_raster <- function(raster, xmin, xmax, ymin, ymax,
interpolate = FALSE) {
raster <- grDevices::as.raster(raster)
if (!inherits(raster, 'nativeRaster'))
raster <- grDevices::as.raster(raster)

layer(
data = dummy_data(),
Expand Down
2 changes: 1 addition & 1 deletion man/annotation_raster.Rd

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