| plot.euler | R Documentation |
Plot diagrams fit with euler() and venn() using grid::Grid() graphics.
This
function sets up all the necessary plot parameters and computes
the geometry of the diagram. plot.eulergram(), meanwhile,
does the actual plotting of the diagram. Please see the Details section
to learn about the individual settings for each argument.
## S3 method for class 'euler'
plot(
x,
fills = TRUE,
patterns = FALSE,
edges = TRUE,
legend = FALSE,
labels = identical(legend, FALSE),
quantities = FALSE,
annotations = NULL,
strips = NULL,
bg = FALSE,
main = NULL,
complement = TRUE,
rotate = 0,
n = 200L,
adjust_labels = TRUE,
...
)
## S3 method for class 'eulerr_venn'
plot(
x,
fills = TRUE,
patterns = FALSE,
edges = TRUE,
legend = FALSE,
labels = identical(legend, FALSE),
quantities = TRUE,
strips = NULL,
bg = FALSE,
main = NULL,
complement = TRUE,
n = 200L,
adjust_labels = TRUE,
...
)
## S3 method for class 'venn'
plot(...)
x |
an object of class |
fills |
a logical, vector, or list of graphical parameters for the fills
in the diagram. Vectors are assumed to be colors for the fills.
See |
patterns |
a logical, vector, or list of graphical parameters for
fill patterns in the diagram. Vectors are assumed to be pattern types
(currently |
edges |
a logical, vector, or list of graphical parameters for the edges
in the diagram. Vectors are assumed to be colors for the edges.
See |
legend |
a logical scalar or list. If a list, the item |
labels |
a logical, vector, or list. Vectors are assumed to be
text for the labels. See |
quantities |
a logical, vector, or list. Vectors are assumed to be
text for the quantities' labels, which by
default are the original values in the input to |
annotations |
free-form per-region text rendered as a third
stacked element below the quantity (or below the label when no
quantity is drawn). Accepts a named character vector keyed by
subset name (e.g. |
strips |
a list, ignored unless the |
bg |
a logical, character, or list controlling the background grob. Character values are interpreted as the background fill color. |
main |
a title for the plot in the form of a
character, expression, list or something that can be
sensibly converted to a label via |
complement |
a logical, character, or list controlling the
container box and complement region for diagrams fit with
|
rotate |
a numeric value giving the angle in degrees by which to rotate
the entire diagram layout. Positive values rotate counter-clockwise.
Defaults to |
n |
number of vertices for the |
adjust_labels |
a logical. If |
... |
parameters to update |
The only difference between plot.euler() and plot.venn() is that
quantities is set to TRUE by default in the latter and FALSE in
the former.
Most of the arguments to this function accept either a logical, a vector, or a list where
logical values set the attribute on or off,
vectors are shortcuts to commonly used options (see the individual parameters), and
lists enable fine-grained control, including graphical
parameters as described in grid::gpar() and control
arguments that are specific to each argument.
The various grid::gpar() values that are available for each argument
are:
| fills | edges | labels | quantities | annotations | strips | legend | main | |
| col | x | x | x | x | x | x | x | |
| fill | x | |||||||
| alpha | x | x | x | x | x | x | x | x |
| lty | x | |||||||
| lwd | x | |||||||
| lex | x | |||||||
| fontsize | x | x | x | x | x | x | ||
| cex | x | x | x | x | x | x | ||
| fontfamily | x | x | x | x | x | x | ||
| lineheight | x | x | x | x | x | x | ||
| font | x | x | x | x | x | x | ||
Defaults for these values, as well as other parameters of the plots, can
be set globally using eulerr_options().
If the diagram has been fit using the data.frame or matrix methods
and using the by argument, the plot area will be split into panels for
each combination of the one to two factors. The fills, patterns, edges,
labels, quantities, and annotations arguments each accept an optional
by_group entry: a named list of override lists keyed by panel name (the
names of the fitted object). For multi-by fits the panel name is the
levels joined by ., e.g. "Male.German". Panels not listed in by_group
use the top-level settings unchanged. Only graphical fields (and rot for
labels, quantities, and annotations) may be overridden per panel;
structural fields such as quantities$type, quantities$format,
annotations$labels, or named-by-subset fills$fill must be set at the
top level.
For users who are looking to plot their diagram using another package, all the necessary parameters can be collected if the result of this function is assigned to a variable (rather than printed to screen).
Provides an object of class 'eulergram' , which is a
description of the diagram to be drawn. plot.eulergram() does the actual
drawing of the diagram.
euler(), plot.eulergram(), grid::gpar(),
grid::grid.polyline(), grid::grid.path(),
grid::grid.legend(), grid::grid.text()
fit <- euler(c("A" = 10, "B" = 5, "A&B" = 3))
# Customize colors, remove borders, bump alpha, color labels white
plot(fit,
fills = list(fill = c("red", "steelblue4"), alpha = 0.5),
labels = list(col = "white", font = 4))
# Add quantities to the plot
plot(fit, quantities = TRUE)
# Add free-form per-region annotations below the counts
plot(
fit,
quantities = TRUE,
annotations = c(A = "mean = 35", "A&B" = "mean = 41")
)
# Add a custom legend and retain quantities
plot(fit, quantities = TRUE, legend = list(labels = c("foo", "bar")))
# Plot without fills and distinguish sets with border types instead
plot(fit, fills = "transparent", lty = 1:2)
# Save plot parameters to plot using some other method
diagram_description <- plot(fit)
# Plots using 'by' argument
plot(euler(fruits[, 1:4], by = list(sex)), legend = TRUE)
# Per-panel styling with `by_group`
plot(
venn(fruits[, 1:4], by = list(sex)),
quantities = list(
by_group = list(
male = list(col = "steelblue"),
female = list(col = "tomato")
)
)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.