MyNixOS website logo
Description

Geoms for Playfair-Style Charts.

Currently provides geom_balance_of_trade(), a 'ggplot2' layer that fills the area between exports and imports series (with automatic crossing detection and conditional coloring for surplus vs. deficit), and overlays lines and points by default.

ggplayfair

R-CMD-check CRAN_Status_Badge

About:

Makes Playfair graphs easier to create using ggplot.

How to Use ggplayfair

This section provides a quickstart guide for installing and using the ggplayfair package to create balance of trade charts with ggplot2.


Installation

Install the latest CRAN release:

#install.packages("ggplayfair")

Or install the development version from GitHub:

# If you don’t have devtools installed:
#install.packages("devtools")
library(devtools)

devtools::install_github("DerekStevens99/ggplayfair")

Basic Usage

Load the package and prepare your data frame. Your data should include:

  • x: the x-axis variable (e.g., year, quarter)
  • exports: numeric values representing deficit lessening activity.
  • imports: numeric values representing deficit driving activity.
library(ggplot2)
library(ggplayfair)

# sample data
df <- data.frame(
  year    = 2000:2010,
  exports = c(50, 55, 60, 58, 62, 65, 63, 67, 70, 72, 75),
  imports = c(45, 50, 52, 55, 58, 60, 100, 120, 68, 70, 74)
)

# one line - geom_balance_of_trade - builds the Playfair‐style ribbon + lines + points
ggplot(df, aes(x = year, exports = exports, imports = imports)) +
  geom_balance_of_trade(alpha = 0.6) +
  scale_fill_manual(
    values = c(surplus = "forestgreen", deficit = "firebrick")
  ) +
  labs(
    title    = "Balance of Trade",
    subtitle = "Exports vs Imports, 2000–2010"
  ) +
  theme_minimal()

Customization

  • Colors: override default with scale_fill_manual() or any scale_fill_*().
  • Themes: apply any ggplot2 theme (e.g., theme_classic(), theme_dark()).
  • Labels: customize with labs() or scale_x_*(), scale_y_*() functions.

Metadata

Version

0.1.1

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-windows
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows