Learn R Programming

gghinton (version 0.1.0)

scale_fill_hinton: Colour scale for Hinton diagrams

Description

Maps the sign-encoding produced by stat_hinton() to the conventional Hinton colour scheme: white for positive values, black for negative values. For unsigned data (all non-negative), all squares are drawn in black.

Usage

scale_fill_hinton(..., values = NULL, guide = "none")

Value

A ggplot2 scale object.

Arguments

...

Additional arguments passed on to ggplot2::scale_fill_manual().

values

Named character vector of colours for "positive", "negative", and "unsigned" fill values. Override individual colours by passing a partial named vector, e.g. values = c(negative = "grey50") merges with the defaults.

guide

Legend guide. Defaults to "none" (no legend).

Details

This scale is a thin wrapper around ggplot2::scale_fill_manual() with the default legend suppressed. Pass guide = "legend" to restore the legend, or override the values argument to use custom colours.

Examples

Run this code
library(ggplot2)
m <- matrix(c(0.8, -0.3, 0.5, -0.9, 0.1, 0.6), 2, 3)
df <- matrix_to_hinton(m)

ggplot(df, aes(x = col, y = row, weight = weight)) +
  geom_hinton() +
  scale_fill_hinton() +
  theme_hinton()

Run the code above in your browser using DataLab