
Last chance! 50% off unlimited learning
Sale ends in
Extensions to 'ggplot2' respecting the grammar of graphics paradigm. Specialization of method ggplot(): accept and convert on the fly time series data. Geom: "table", "plot" and "grob" add insets to plots using native data coordinates, while "table_npc", "plot_npc" and "grob_npc" do the same using "npc" coordinates through new aesthetics "npcx" and "npcy". Statistics: locate and tag peaks and valleys; count observations in different quadrants of a plot; select observations based on 2D density; label with the equation of a polynomial fitted with lm() or other types of models; labels with P-value, R^2 or adjusted R^2 or information criteria for fitted models; label with ANOVA table for fitted models; label with summary for fitted models. Model fit classes for which suitable methods are provided by package 'broom' are supported. Scales and stats to build volcano and quadrant plots based on outcomes, fold changes, p-values and false discovery rates.
geom_null()
, stat_debug_group()
,
stat_debug_panel()
, geom_debug()
, append_layers()
,
bottom_layer()
, delete_layers()
, extract_layers()
,
move_layers()
, num_layesr()
, shift_layers()
,
top_layer()
and which_layers()
have been moved from package
'ggpmisc' into their own seperate package
'gginnards-package
.
We thank Kamil Slowikowski not only for
contributing ideas and code examples to this package but also for adding
new features to his package 'ggrepel' that allow new use cases for
stat_dens2d_labels
from this package.
The new facilities for cleanly defining new stats and geoms added to 'ggplot2' in version 2.0.0 and the support for nested tibbles and new syntax for mapping computed values to aesthetics added to 'ggplot2' in version 3.0.0 are used in this package's code. This means that 'ggpmisc' (>= 0.3.0) requires version 3.0.0 or later of ggplot2 while 'ggpmisc' (< 0.3.0) requires version 2.0.0 or later of ggplot2.
Extensions provided:
Function for conversion of time series data into tibbles that can be plotted with ggplot.
ggplot()
method for time series data.
Stats for locating and tagging "peaks" and "valleys" (local or global maxima and minima).
Stat for generating labels from a lm()
model fit, including
formatted equation. By default labels are expressions but tikz device is
supported optionally with LaTeX formatted labels.
Stats for extracting information from a any model fit supported by package 'broom'.
Stats for filtering-out/filtering-in observations in regions of a panel or group where the density of observations is high.
Geom for annotating plots with tables.
The stats for peaks and valleys are coded so as to work correctly both with numeric and POSIXct variables mapped to the x aesthetic. Special handling was needed as text labels are generated from the data.
Package suite 'r4photobiology' web site at https://www.r4photobiology.info/ Package 'ggplot2' documentation at https://ggplot2.tidyverse.org/ Package 'ggplot2' source code at https://github.com/hadley/ggplot2
Useful links:
# NOT RUN {
library(tibble)
ggplot(lynx, as.numeric = FALSE) + geom_line() +
stat_peaks(colour = "red") +
stat_peaks(geom = "text", colour = "red", angle = 66,
hjust = -0.1, x.label.fmt = "%Y") +
ylim(NA, 8000)
formula <- y ~ poly(x, 2, raw = TRUE)
ggplot(cars, aes(speed, dist)) +
geom_point() +
geom_smooth(method = "lm", formula = formula) +
stat_poly_eq(aes(label = stat(eq.label)), formula = formula,
parse = TRUE)
formula <- y ~ x
ggplot(PlantGrowth, aes(group, weight)) +
stat_summary(fun.data = "mean_se") +
stat_fit_tb(method = "lm",
method.args = list(formula = formula),
tb.type = "fit.anova") +
theme_classic()
# }
Run the code above in your browser using DataLab