Miscellaneous Extensions to 'ggplot2'

Extensions to 'ggplot2' respecting the grammar of graphics paradigm. Provides new statistics to locate and tag peaks and valleys in 2D plots, a statistics to add a label with the equation of a polynomial fitted with lm(), or R^2 or adjusted R^2 or information criteria for any model fitted with function lm(). Additional statistics give access to functions in package 'broom'. Provides a function for flexibly converting time series to data frames suitable for plotting with ggplot(). In addition provides statistics and ggplot geometries useful for diagnosing what data are passed to compute_group() and compute_panel() functions and to geometries.


Package 'ggpmisc' (Miscellaneous Extensions to 'ggplot2') is a set of extensions to R package 'ggplot2' (> 2.2.1) useful when plotting diverse types of data.

Functions try_data_frame() and try_tibble() can be used to convert time series objects into data frames or tibbles suitable for plotting. To complement these functions ggplot methods for "ts" and "xts" classes are defined.

A geometry, geom_table() allows adding tables from tibble objects mapped to the label aesthetic.

Two statistics automate finding the location and labeling peaks and/or valleys.

Several statistics are provided for annotations related to model fits: fitted polynomial equations as labels, fitted equations for other model fits including non-linear ones, ANOVA tables, model summary tables, highlighting deviations from a fitted curve, and plotting residuals on-the-fly.

Statistics are provided for filtering and/or tagging data from regions of plot panels with high/low densities of observations (the stats are designed to work nicely together with package 'ggrepel').

Another group of ggplot statistics and geometries which echo their data input to the R console and/or plot aim at easing debugging during development of new geoms and statistics (or learning how ggplot layers work).

Please, see the web site r4photobiology for details and update notices, and the docs site. Other packages, aimed at easing photobiology-related calculations including the quantification of biologically effective radiation in meteorology are available as part of a suite described at the same website.

The current release of 'ggpmisc' is available through CRAN for R (>= 3.3.0).

News

ggpmisc 0.2.16

  • Revise stat_fit_tidy() so that it returns p-values for parameters, in additon to estimates and their standard errors.
  • BUG FIX: Revise geom_debug() adding missing default arguments.
  • Add functions for manipulation of layers in ggplot objects: delete_layers(), append_layers(), move_layers(), shift_layers(), which_layers(), extract_layers(), num_layers(), top_layer() and bottom_layer().

ggpmisc 0.2.15

Add stat_fit_tidy() implemented using broom::tidy(). Makes it possible to add the fitted equation for any fitted model supported by package 'broom', as long as the user supplies within aes() the code to build a label string. Update user guide.

ggpmisc 0.2.14

Fix bug in stat_poly_equation() eq.x.rhs argument ignored when using expressions.

ggpmisc 0.2.13

Fix bugs in try_tibble() and try_data_frame() which made them fail silently with some objects of class "ts" in the case of numeric (decimal date) index for time. In addition lack of special handling for classes "yearmon" and "yearqrt" from package 'zoo', lead to erroneous date shifts by a few days. Add methods ggplot.ts() and ggplot.xts().

ggpmisc 0.2.12

Change default value for parameter label.fill in stat_dens2d_labels() from NA to "". Improve documentation using current 'ggrepel' version, which implements changes that make stat_dens2d_labels() useful.

ggpmisc 0.2.11

Add stat_dens2d_labels(), a statistic that resets label values to NA by default, or any character string supplied as argument, in regions of a panel with high density of observations. Add stat_den2d_filter(), a statistic that filters-out/filters-in observations in regions of a panel with high density of observations. These two statistics are useful for labelling or highlighting observations in regions of a panel with low density. Both stats use a compute_panel function. Add stat_den2d_filter_g(), a statistic that filters-out/filters-in observations in regions of a group with high density of observations. This statistics is useful for highlighting observations. It uses a compute_group function. They use internally MASS:kde2d to estimate densities and default values for parameters are adjusted dynamically based on the number of observations.

ggpmisc 0.2.10

Add user-requested feature: allow user to specify number 'digits' used in formatting numbers in labels in stat_poly_eq(). Update try_data_frame() to return an object of class "tibble" and add try_tibble() as synonym. Update documentation and start using package 'staticdocs' to build a documentation web site.

ggpmisc 0.2.9

Add support for tikz in stat_poly_eq(). Fix bug in stat_poly_eq(). Fix bug in geom_debug(). Fix bug in stat_fit_augment().

ggpmisc 0.2.8

Enhance stat_poly_eq() so that 1) position of labels according to npc (relative positions using normalized coordinates), as well as by named positions "top", "bottom", "right", "left" and "center" is now implemented; 2) when grouping is present, suitable vjust values are computed to automatically position the labels for the different groups without overlap. Default label positions are now relative to the range of each panel's $x$ and $y$ scales, eliminating in most cases the need to manually tweak label positions.

Add stat_fit_glance() uses package 'broom' for maximum flexibility in model function choice when wanting to add labels based on information from a model fit, at the expense of very frequently having to explicitly set aesthetics, and always having to add code to do the formatting of the values to be used in labels. Label position is as described above for stat_poly_eq().

Add stat_fit_deviations() for highlighting residuals in plots of fitted models. This statistic currently supports only lm() fits. By default geom "segment" is used to highlight the deviations of the observations from a fitted model.

Add stat_fit_residuals() for plotting residuals from a fitted model on their own in plots matching plots of lm fits plotted with stat_smooth() even with grouping or facets. This statistic currently supports only lm() fits. By default geom "point" is used to plot the residual from a fitted model.

Add preliminary version of stat_fit_augment(), which uses package 'broom' for maximum flexibility in model function choice, to augment the data with additional columns of values derived from a model fit.

ggpmisc 0.2.7

Add support for AIC and BIC labels to stat_poly_eq(). Add pretty-printing of parameter values expressed in engineering notation in stat_poly_eq(). Add support for user-supplied label coordinates in stat_poly_eq(). Improve stat_debug_panel() and stat_debug_group() so that they can optionally print to the console a summary of the data received as input. Add geom_debug(), a geom that summarizes its data input to the console, and produces no visible graphical output.

ggpmisc 0.2.6

Add support for user-supplied lhs and for user-supplied rhs-variable name in the equation label in stat_poly_eq().

ggpmisc 0.2.5

Remove one example to remove a package dependency.

ggpmisc 0.2.4

Improve handling of time zones in try_data_frame(). Revise documentation and vignette.

ggpmisc 0.2.3

stat_poly_eq() changed to include the lhs (left hand side) of the equation by default.

ggpmisc 0.2.2

Add function try_data_frame() to convert R objects including time series objects of all classes accepted by try.xts() into data frames suitable for plotting with ggplot().

Update stat_peaks() and stat_valleys() to work correctly when the x aesthetic uses a Date or Datetime continuous scale such as ggplot() sets automatically for POSIXct variables mapped to the x aesthetic.

ggpmisc 0.2.1

Rename stat_debug() as stat_debug_group() and add stat_debug_panel(). Add stat_peaks() and stat_valleys() (these are simpler versions of ggspectra::stat_peaks() and ggspectra::stat_valleys() for use with any numerical data (rather than light spectra).

ggpmisc 0.1.0

First version. Add stat_poly_eq() Add stat_debug()

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("ggpmisc")

0.2.16 by Pedro J. Aphalo, 5 months ago


http://www.r4photobiology.info, https://bitbucket.org/aphalo/ggpmisc


Report a bug at https://bitbucket.org/aphalo/ggpmisc/issues


Browse source code at https://github.com/cran/ggpmisc


Authors: Pedro J. Aphalo [aut, cre], Kamil Slowikowski [ctb]


Documentation:   PDF Manual  


GPL (>= 2) license


Imports methods, tibble, MASS, polynom, splus2R, plyr, dplyr, xts, zoo, broom, lubridate

Depends on ggplot2

Suggests knitr, rmarkdown, nlme, ggrepel


See at CRAN