Convert colors to imitate greyscale printing

后端 未结 4 1336
孤街浪徒
孤街浪徒 2021-01-21 06:07

When reading this question, I started to think whether it would be possible to convert colors to imitate an average greyscale printer (assuming that your screen is calibrated)?

相关标签:
4条回答
  • 2021-01-21 07:01

    Use an HCL palette with chroma set to zero to create greyscale values that are indistinguishable to the human eye.

    library(colorspace)
    n <- 10
    cols <- rainbow_hcl(n)
    plot(seq_len(n), cex = 5, pch = 20, col = cols)
    
    greys <- rainbow_hcl(n, c = 0)
    plot(seq_len(n), cex = 5, pch = 20, col = greys)
    

    If you want to generate the greys from your original colours, use the scales package.

    library(scales)
    greys2 <- col2hcl(cols, c = 0)
    plot(seq_len(n), cex = 5, pch = 20, col = greys2)
    
    0 讨论(0)
  • 2021-01-21 07:01

    The col2grey (and/or col2gray) function in the TeachingDemos package uses one common method for doing this. The idea is to see what your colors will look like when printed or copied in grayscale instead of color.

    0 讨论(0)
  • 2021-01-21 07:01

    The desaturate() function in the `colorspace package can also be used to convert colors to their gray levels only. This collapses chroma (colorfulness) in the HCL (or polar CIELUV) representation of the colors.

    plot(1:4, type = "p",
      col = colorspace::desaturate(c(Rl, Rd, Cl, Cd)),
      pch = 19, cex = 8, xlim = c(0,5), ylim = c(0,5))
    

    0 讨论(0)
  • 2021-01-21 07:01

    You can use one of the 3 conversion algorithms outlined here, and just determine if they're outside whatever tolerance you think is too similar.

    0 讨论(0)
提交回复
热议问题