inset {memery} | R Documentation |
Meme plot inset templates
Description
Templates for the position and background of a ggplot inset.
Usage
inset_position(type = "default", size = 0.2, margin = 0.025)
inset_background(type = "default")
inset_templates(type)
Arguments
type |
character, name of template. |
size |
numeric, width (length-1) or width and height (length-2) of inset. See details. |
margin |
numeric, x-axis margin (length-1) or x- and y-axis margins (length-2) around corner insets. See details. |
Details
inset_position
and inset_background
assist with some basic options for position and background of the optional ggplot inset graphic.
inset_templates
can be used to view the available templates. See examples.
If a template is not available to suit your needs, provide your own argument list to meme
in the form of, e.g., inset_pos = list(w = 0.95, h = 0.6, x = 0.5, y = 0.325)
.
Value
a list of arguments passed to either inset_pos
or inset_bg
in meme
.
Size and position
The coordinate system for the meme plot ranges from zero to one in x and y.
The width, height and (x,y) center defined by inset_position
arguments therefore take values between zero and one.
The default position is for an inset plot that takes up 95% of the width and 60% of the height of the meme plot,
with 2.5% margins on the sides and bottom. Other templates include four corner thumbnails.
To use these, set type
equal to "tl"
, "tr"
, "br"
or "bl"
,
for top right, top left, bottom right and bottom left, respectively.
There is also a "center"
type.
When specifying the corner or center inset types, the inset is a square thumbnail with width and height of 0.2 units (20%)
and 0.025 (2.5%) margins from the edges of the plot. However, these templates are not absolute.
You can further adjust the size and distance from the edges using size
and margin
.
These arguments can be scalar, in which case the inset remains square and the margins are equal.
If a length-2 vector, size
can provide unique width and height for a rectangular inset.
Similarly, margin
can provide different margins for the distance to a side vs. the top or bottom edge of the meme plot.
For type = "center"
, size
is used but margin
is ignored, giving you control over the thumbnail size.
Appending the letter q
to a corner thumbnail template ID, e.g. type = "blq"
, yields a quadrant plot.
In contrast to type = "center"
, these types allow for user control over margins for plots of fixed coverage area.
Specifying the right combination of size
and margin
with a corner thumbnail template can be used to create a
quadrant plot, but using a quadrant template simplifies this.
size
and margin
are provided for convenience, adding more control over the position templates.
If you require more specific size and position control, simply pass your own 4-argument list as described above.
This is the structure generated by inset_position
for any type
and expected by meme
.
Background
For inset_background
, the few templates all revolve around the type = "default"
template.
type = "sq"
simply removes the rounded corners. "op"
provides a fully opaque white background instead of the default 50% transparency.
"opsq"
does both. "blank"
hides the background panel.
There is no substantial need to provide many templates because, as with inset_position
,
inset_background
generates a simple list of a few arguments that can be easily provided to meme
explicitly
without the use of inset_background
.
Examples
inset_templates("position")
inset_templates("background")
inset_position()
inset_position("br")
inset_position("brq", margin = 0.05)
inset_position("br", size = 0.4, margin = 0)
inset_background()
inset_background("opsq")
inset_background("blank")