Title: | Graphics Layers for Plotting Image Data with 'ggplot2' |
---|---|
Description: | Provides two new layer types for displaying image data as layers within the Grammar of Graphics framework. Displays images using either a rectangle interface, with a fixed bounding box, or a point interface using a central point and general size parameter. Images can be given as local JPEG or PNG files, external resources, or as a list column containing raster image data. |
Authors: | Taylor B. Arnold [aut, cre] |
Maintainer: | Taylor B. Arnold <[email protected]> |
License: | GPL-2 |
Version: | 0.1.2 |
Built: | 2024-11-08 04:28:01 UTC |
Source: | https://github.com/statsmaths/ggimg |
Display Images from Bounding Boxes
geom_point_img( mapping = NULL, data = NULL, stat = "identity", position = "identity", show.legend = NA, inherit.aes = TRUE, ..., hjust = 0.5, vjust = 0.5, along = "width", interpolate = TRUE ) GeomPointImage
geom_point_img( mapping = NULL, data = NULL, stat = "identity", position = "identity", show.legend = NA, inherit.aes = TRUE, ..., hjust = 0.5, vjust = 0.5, along = "width", interpolate = TRUE ) GeomPointImage
mapping |
Set of aesthetic mappings created by [aes()] or [aes_()]. If specified and 'inherit.aes = TRUE' (the default), it is combined with the default mapping at the top level of the plot. You must supply 'mapping' if there is no plot mapping. |
data |
The data to be displayed in this layer. There are three options: If 'NULL', the default, the data is inherited from the plot data as specified in the call to [ggplot()]. A 'data.frame', or other object, will override the plot data. All objects will be fortified to produce a data frame. A 'function' will be called with a single argument, the plot data. The return value must be a 'data.frame', and will be used as the layer data. A 'function' can be created from a 'formula' (e.g. '~ head(.x, 10)'). |
stat |
The statistical transformation to use on the data for this layer, as a string. |
position |
Position adjustment, either as a string, or the result of a call to a position adjustment function. |
show.legend |
logical. Should this layer be included in the legends? 'NA', the default, includes if any aesthetics are mapped. 'FALSE' never includes, and 'TRUE' always includes. It can also be a named logical vector to finely select the aesthetics to display. |
inherit.aes |
If 'FALSE', overrides the default aesthetics, rather than combining with them. This is most useful for helper functions that define both data and aesthetics and shouldn't inherit behaviour from the default plot specification, e.g. [borders()]. |
... |
Other arguments passed on to [layer()]. These are often aesthetics, used to set an aesthetic to a fixed value. |
hjust |
A numeric vector specifying horizontal justification. 0 means left alignment and 1 means right alignment. The default of 0.5 gives center alignment. |
vjust |
A numeric vector specifying vertical justification. 0 means left alignment and 1 means right alignment. The default of 0.5 gives center alignment. |
along |
Either 'width' (default) or 'height'. For the point method, the aspect ratio of the image will be preserved. Specifies whether size should be relative to the plot's with or height. |
interpolate |
A logical value indicating whether to linearly interpolate the image (the alternative is to use nearest-neighbour interpolation, which gives a more blocky result). |
An object of class GeomPointImage
(inherits from Geom
, ggproto
, gg
) of length 6.
Taylor B. Arnold, [email protected]
library(ggplot2) posters$path <- file.path( system.file("extdata", package="ggimg"), posters$img ) p_paths <- ggplot(posters) + geom_point_img(aes( x = year, y = stars, img = path ), size = 1.1)
library(ggplot2) posters$path <- file.path( system.file("extdata", package="ggimg"), posters$img ) p_paths <- ggplot(posters) + geom_point_img(aes( x = year, y = stars, img = path ), size = 1.1)
Display Images from Bounding Boxes
geom_rect_img( mapping = NULL, data = NULL, stat = "identity", position = "identity", show.legend = NA, inherit.aes = TRUE, ..., interpolate = TRUE ) GeomRectImage
geom_rect_img( mapping = NULL, data = NULL, stat = "identity", position = "identity", show.legend = NA, inherit.aes = TRUE, ..., interpolate = TRUE ) GeomRectImage
mapping |
Set of aesthetic mappings created by [aes()] or [aes_()]. If specified and 'inherit.aes = TRUE' (the default), it is combined with the default mapping at the top level of the plot. You must supply 'mapping' if there is no plot mapping. |
data |
The data to be displayed in this layer. There are three options: If 'NULL', the default, the data is inherited from the plot data as specified in the call to [ggplot()]. A 'data.frame', or other object, will override the plot data. All objects will be fortified to produce a data frame. A 'function' will be called with a single argument, the plot data. The return value must be a 'data.frame', and will be used as the layer data. A 'function' can be created from a 'formula' (e.g. '~ head(.x, 10)'). |
stat |
The statistical transformation to use on the data for this layer, as a string. |
position |
Position adjustment, either as a string, or the result of a call to a position adjustment function. |
show.legend |
logical. Should this layer be included in the legends? 'NA', the default, includes if any aesthetics are mapped. 'FALSE' never includes, and 'TRUE' always includes. It can also be a named logical vector to finely select the aesthetics to display. |
inherit.aes |
If 'FALSE', overrides the default aesthetics, rather than combining with them. This is most useful for helper functions that define both data and aesthetics and shouldn't inherit behaviour from the default plot specification, e.g. [borders()]. |
... |
Other arguments passed on to [layer()]. These are often aesthetics, used to set an aesthetic to a fixed value. |
interpolate |
A logical value indicating whether to linearly interpolate the image (the alternative is to use nearest-neighbour interpolation, which gives a more blocky result). |
An object of class GeomRectImage
(inherits from Geom
, ggproto
, gg
) of length 6.
Taylor B. Arnold, [email protected]
library(ggplot2) posters$path <- file.path( system.file("extdata", package="ggimg"), posters$img ) p_paths <- ggplot(posters) + geom_rect_img(aes( xmin = year - 0.5, xmax = year + 0.5, ymin = stars - 0.5, ymax = stars + 0.5, img = path ))
library(ggplot2) posters$path <- file.path( system.file("extdata", package="ggimg"), posters$img ) p_paths <- ggplot(posters) + geom_rect_img(aes( xmin = year - 0.5, xmax = year + 0.5, ymin = stars - 0.5, ymax = stars + 0.5, img = path ))
Given an input, either a URL, local file path, or a RasterImage itself, return an array of the image file.
gimg_load_img(input)
gimg_load_img(input)
input |
the input as either a path, url, or the image itself |
An array with the image.
Data frame containing information about the 50 top grossing animated U.S.
films from 2000-2019. The column points to a thumbnail of the movie's
promotional poster, installed along with the package. See geom_img
for an example of using it with the package.