Coder Social home page Coder Social logo

cetcolor's Introduction

cetcolor

R-CMD-check CRAN_Status_Badge CRAN RStudio mirror downloads

The cetcolor package is designed to bring to R the 56 colour maps created by Peter Kovesi that avoid points of locally high colour contrast leading to the perception of false anomalies in your data when there is none. The colour maps have been designed to avoid this phenomenon by having uniform perceptual contrast over their whole range.

Installation

The cetcolor package is available on both CRAN and GitHub. The CRAN version is considered stable while the GitHub version is in a state of development and may break.

You can install the stable version of the cetcolor package with:

install.packages("cetcolor")

For the development version, you can opt for:

install.packages("remotes")
remotes::install_github("coatless-rpkg/cetcolor")

Sample Usage

# Load the Library
library("cetcolor")

# Get RGB Hexadecimals for graphing
cet_pal(5, name = "blues")
#> [1] "#F1F1F1" "#C0D3EB" "#93B5DD" "#7197C1" "#3B7CB2"

# Sample use with ggplot2
library("ggplot2")

ggplot(faithfuld, aes(waiting, eruptions)) +
  geom_raster(aes(fill = density)) +
  theme_bw() + theme(panel.grid=element_blank()) -> g

library("gridExtra")

# Frequently used colour maps have "nicknames" see ?cet_color_maps 
grid.arrange(
  g + scale_fill_gradientn(colours = cet_pal(5, name = "fire")),
  g + scale_fill_gradientn(colours = cet_pal(5, name = "inferno")),
  g + scale_fill_gradientn(colours = cet_pal(5, name = "blues")),
  g + scale_fill_gradientn(colours = cet_pal(5, name = "kgy")),
  ncol = 2, nrow = 2
)

# Show a panel of possible values (without nicknames)
display_cet_all()

References

CET

R Colour Palettes

  • viridis (Source)
    • Provides MATLAB perceptually uniform colour maps in a manner that is similar to this package.
  • RColorBrewer (Source)
    • Function interface naming, e.g. cet_pal(n, name), and colour map displays.
  • scales and ggplot2
    • Proper ways to interface colour palettes with ggplot2 as shown for RColorBrewer.

Future

  • Allow for n > 256.
  • Provide hooks for ggplot2 gradient and discrete scales
  • Port over the Peter’s generation code from Julia / MATLAB to R.

Authors

James Balamuta and Peter Kovesi

License

CC BY-SA 4.0

cetcolor's People

Contributors

coatless avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

cetcolor's Issues

Glasbey palettes

For those who came here looking for a Python colorcet implementation, you'll find the Glasbey palettes missing.

These can be converted quite easily though. Download the assets folder from colorcet then:

  GlasbeyCsvDir <- r"(...\)"  
  fn <- glue("{GlasbeyCsvDir}glasbey_hv_n256.csv")
  
  data <- readr::read_csv( fn,
                   col_names = c("R", "G", "B"),
                   col_types = c("d", "d", "d")
                   )  
  glPal <- rgb(data)

Not as convenient as the cetcolor package of course.

Rename color palettes to new code system

Switch naming scheme to codes

Dropped the CET- prefix and use lowercase letters, e.g. d1, i1, ...

c.f.

In practice I simply refer to the colour maps by a number prefixed by one or two characters to indicate whether the map is linear (l), diverging (d), rainbow (r), cyclic(c), isoluminant (i) or colour blind (cb). Thus, for example, the linear greyscale is 'l1' or 'cet-l1', the heat colour map is 'l3' or 'cet-l3' and the blue-white-red diverging map is 'd1' or 'cet-d1' etc, etc. In the visual catalogue shown further below you will see each colour map with both its simple and complex names.

https://peterkovesi.com/projects/colourmaps/

Update to latest version of palette namings

@peterkovesi do you by chance have any update notes as to how the color palettes have changed recently? Anything with respect to the rename of old palettes found in 2018.

I'm seeing a bunch of new names and existing palettes having ~3 decimal places instead of 5 decimal places.

82ec912

Allow for n > 256.

Figure out a way to get a more generalized gradient so plots using greater than 256 colors can be used.

Release 0.1.0 - `cetcolor`

  • Run against winbuilder
  • Update NEWS.md
  • Update DESCRIPTION version number
  • Mark a new release upon CRAN upload

Add unit tests

No code coverage at the moment.

Could be useful in the future.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.