--- title: "Unified Interface (with Formula) for R Plots" author: "Philippe Grosjean" date: "`r Sys.Date()`" output: rmarkdown::html_vignette: toc: true toc_depth: 3 fig_caption: yes vignette: > %\VignetteIndexEntry{Unified Interface (with Formula) for R Plots} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- ```{r setup, include=FALSE} knitr::opts_chunk$set(collapse = TRUE, comment = "#>") library(chart) ``` ## Introduction In R, there are several plotting engines, but the three major ones are the base {graphics} package (here called "base plot"), {lattice} and {ggplot2}. Each of them has its own philosophy and syntax. The plots they produce have distinctive look, even if they can be tailored to different styles. The {chart} package provides a unified interface to these three plotting engines. The goal of {chart} is: - to provide a unified interface to the three major plotting engines in R; - to make all three types of plots compatible in a composite figure; - to propose a default style for the plots that is consistent across the three engines and close enough to a publication-ready style; - to use automatically labels and units for axes, when possible; - to expose an formula-base interface as an alternative for {ggplot2} users; - to implement various (customizable) plot types for different R objects. ## {chart} for {ggplot2} users The {chart} package uses {ggplot2} in priority. It is designed to be as close as possible to the {ggplot2} syntax with the following four exceptions: 1. You should use `chart()` instead of `ggplot()`. The `chat()` function is backward compatible with `ggplot()` and you can use the same syntax, but it also uses an alternate formula-based interface. On the contrary to `ggplot()`, `chart()` automatically use labels and units for axes and legends, it uses a default style closer to a "publication-ready" format, and it is a generic function that provides different methods (and different plot types for each method). 2. You can use a formula instead of an `aes()` to specify the aesthetics.