Description Usage Arguments Details Comparison with the ggplot2 package
text text
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | plot3(
.data,
type = "column",
x = NULL,
y = NULL,
category = NULL,
facet = NULL,
title = NULL,
subtitle = NULL,
tag = NULL,
caption = NULL,
bins = NULL,
category.focus = NULL,
category.sort = TRUE,
colour = getOption("plot2.colours", "certe"),
colour.extended_spectrum = FALSE,
colour.fill = NULL,
colour.opacity = 0,
datalabels = TRUE,
datalabels.fill = "white",
datalabels.round = if_else(y.percent, 1, 2),
datalabels.size = 3,
decimal_comma = uses_decimal_comma(),
facet.bold = TRUE,
facet.drop = FALSE,
facet.fill = NULL,
facet.fixed_y = FALSE,
facet.italic = FALSE,
facet.margin = 8,
facet.nrow = NULL,
facet.position = "top",
facet.relative = FALSE,
facet.repeat_lbls_x = TRUE,
facet.repeat_lbls_y = TRUE,
facet.size = 10,
facet.sort = TRUE,
horizontal = FALSE,
jitter_seed = 1,
legend.barheight = 5,
legend.barwidth = 1,
legend.italic = FALSE,
legend.position = "top",
legend.reverse = NULL,
legend.title = "",
linetype = 1,
markdown = TRUE,
na.replace = "(onbekend)",
na.rm = FALSE,
print = FALSE,
reverse = horizontal,
size = ifelse(type %in% c("point", "jitter", "boxplot", "violin"), 2, 0.75),
stacked = FALSE,
stackedpercent = FALSE,
subtitle.maxlength = 60,
summarise_function = base::sum,
text.factor = 1,
text.font_family = "Calibri",
theme = theme_minimal2(),
title.maxlength = 60,
width = ifelse(type %in% c("jitter", "boxplot", "violin"), 0.75, 0.5),
x.date_breaks = "1 day",
x.date_labels = "d mmm",
x.expand = 0.5,
x.lbl_align = NULL,
x.lbl_angle = 0,
x.lbl_italic = FALSE,
x.limits = NULL,
x.max_items = Inf,
x.max_txt = "(rest, x{n})",
x.position = "bottom",
x.remove = FALSE,
x.sort = TRUE,
x.title = NULL,
y.24h = FALSE,
y.age = FALSE,
y.breaks = NULL,
y.expand = 0.25,
y.labels = NULL,
y.limits = NULL,
y.percent = FALSE,
y.percent_break = 10,
y.position = "left",
y.remove = FALSE,
y.title = NULL,
y.trans = "identity",
...
)
## Default S3 method:
plot3(
x,
y = NULL,
type = "p",
xlim = NULL,
ylim = NULL,
log = "",
main = NULL,
sub = NULL,
xlab = NULL,
ylab = NULL,
ann = par("ann"),
axes = TRUE,
frame.plot = axes,
panel.first = NULL,
panel.last = NULL,
asp = NA,
xgap.axis = NA,
ygap.axis = NA,
...
)
## S3 method for class 'grouped_df'
plot3(.data, ..., category = NULL)
## S3 method for class 'ggplot'
plot3(plot, type, ...)
## S3 method for class 'sf'
plot3(
.data,
...,
datalabels = FALSE,
legend.position = "right",
colour = "grey50",
y.expand = 0,
x.expand = 0
)
|
type |
1-character string giving the type of plot desired. The
following values are possible, for details, see |
x |
the |
y |
the |
... |
other graphical parameters (see |
xlim |
the x limits (x1, x2) of the plot. Note that The default value, |
ylim |
the y limits of the plot. |
log |
a character string which contains |
main |
a main title for the plot, see also |
sub |
a sub title for the plot. |
xlab |
a label for the x axis, defaults to a description of |
ylab |
a label for the y axis, defaults to a description of |
ann |
a logical value indicating whether the default annotation (title and x and y axis labels) should appear on the plot. |
axes |
a logical value indicating whether both axes should be drawn on
the plot. Use graphical parameter |
frame.plot |
a logical indicating whether a box should be drawn around the plot. |
panel.first |
an ‘expression’ to be evaluated after the
plot axes are set up but before any plotting takes place. This can
be useful for drawing background grids or scatterplot smooths. Note
that this works by lazy evaluation: passing this argument from other
|
panel.last |
an expression to be evaluated after plotting has
taken place but before the axes, title and box are added. See the
comments about |
asp |
the y/x aspect ratio, see |
xgap.axis |
the x/y axis gap factors, passed as
|
ygap.axis |
the x/y axis gap factors, passed as
|
The plot3()
function uses the ggplot2
package for plotting and provides:
A convenient wrapper around many ggplot2
functions such as ggplot()
, geom_col()
, facet_wrap()
, labs()
, etc.
Writing as few lines of codes as possible
A drop-in replacement for most plot()
calls
Benefits from Excel: the y axis starts at 0, the y scale contains extra space to read all data points, date breaks can be written in a readable format such as "d mmm yyyy", and data labels can easily be printed
Easy plotting in three 'directions': x
(the regular x axis), category
(replaces 'fill' and 'colour') and facet
Easy way for sorting data in may ways (such as on alphabet, numeric value, frequency, original data order), by setting a single argument for the 'direction': x.sort
, category.sort
and facet.sort
Easy limiting values for x
by setting code{x.max_items
Markdown support for any label, with any theme
An extra clean, minimalistic theme with a lot of whitespace that is ideal for printing
The plot3()
function is arguably what the qplot()
function of the ggplot2
package could have been.
ggplot2
packageThe ggplot2
package provides a wide range of functions for very advanced plotting, but it lacks convenience for simple plotting. For example, a common data set could look like this:
1 2 3 4 5 6 7 | df
#> carmodel mpg
#> <chr> <dbl>
#> 1 Mazda RX4 21.0
#> 2 Mazda RX4 Wag 21.0
#> 3 Datsun 710 22.8
#> 4 Hornet 4 Drive 21.4
|
The ggplot2
package sets no default for plotting types, requiring you to type at least:
1 2 | ggplot(df) +
geom_col(aes(x = carmodel, y = mpg))
|
That's a lot of code containing three functions for something so obvious. Any addition (labels, scales, etc.) would require you to write more functions and their parameters. The plot3()
function guesses what you want to do and contains many parameters to alter your plots. In other words, the ggplot2
package requires you to write many functions and parameters for plotting, the plot3()
function only requires you to write the parameters that are not already set:
1 2 |
Moreover, the ggplot2
package requires a data.frame as input or forces input to a data.frame. The plot3()
function uses S3 classes for extensions, allowing base
plot()
users to change their plots to ggplot2
plots by literally adding one number to the function they are calling. And plot3()
functions are even extendible with new plot3()
functions and with other packages.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.