MyNixOS website logo
Description

Create Colour Scales and Legend from Continuous or Categorical Vectors.

Streamlines the steps for adding colour scales and associated legends when working with base R graphics, especially for interactive use. Popular palettes are included and pretty legends produced when mapping a large variety of vector classes to a colour scale. An additional helper for adding axes and grid lines complements the base::plot() work flow.

paletteknife

CRAN status Lifecycle: stable

The goal of paletteknife is to make assigning colour scales, adding legends, and adjusting axes a more effortless task when using R base graphics.

The principal functions included are:

  • autocol() - creates a colour vector from a continuous or categorical vector
  • autolegend() - draws a legend with the last autocol() scales
  • autoaxis() - adds more axes labels and gridlines
  • autopal() - creates a colour palette between limits

Extensive examples have been included, see ?autocol and ?autolegend for starters. Functions themselves are relatively simple but serve as shortcuts so that adding a colour scale and legend can be done in-line and interactively, contributing to a smoother worflow.

For deployment, the underlying base functions can be extracted and embedded if minimal dependencies are required. With that aim, viridisLite and RColorBrewer palettes are included so that these tools are as portable as possible.

Suggestions and contributions are very welcome for further base graphics tasks which can be helpfully streamlined. See maintainer contact details and repository.

Installation

You can install the released version of paletteknife from CRAN with:

install.packages('paletteknife')

Example

This is a basic example which shows you how to solve a common problem:

library(paletteknife)

pals_display(pals = pals.rcolorbrewer)

aq_dates = seq(as.Date('1973-05-01'), by=1, length.out=nrow(airquality))
with(airquality, plot(aq_dates, Temp, pch=16, cex=Solar.R/100, col=autocol(Ozone, set='Reds'),
                      xaxt='n', xlab='', main='New York Air Quality'))

autoaxis(side=1, major='week', major_grid=TRUE, minor='day', las=2, format='%d %b')
autoaxis(side=2, minor=1, minor_grid=TRUE)

autolegend(ncol=5, title='Size: Solar, Colour: Ozone')  # Click on plot

Metadata

Version

0.4.2

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • 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