[x] Tag the issue(s) or milestones this PR fixes (e.g. Fixes #123, Resolves #456).
[x] Describe the changes you've made.
[x] Describe any tests you have conducted to confirm that your changes behave as expected.
Overview
This PR adds functionality for simulating color vision deficiency under the cvd module.
addresses #15, enabling simulation of cvd in deuteranomaly, protanomaly, and tritanomaly spaces.
includes a variety of methods for visualizing color vision deficiency of colors (as HexCode objects), palettes, and gradients under cvd.simulate_color, cvd.simulate_palette, and cvd.simulate_gradient. These methods return a transformed version of the color.
includes a variety of methods for quickly displaying the original color + transformed colors under cvd.simulate_color_all, cvd_simulate_palette_all, and cvd.simulate_gradient_all. These methods return None but display all 4 color spaces (normal, d, p, and t).
includes cvd.simulate_gradient_lightness() to display gradient lightness for all three major types of color vision deficiency.
In addition, this PR adds some helpful utilities to the Palette and Gradient classes:
a swatch() method for Palette, which displays all the colors in the palette as a single strip of swatches prior to the specific color swatches, which has parallel functionality to the swatch() method for Gradient.
a .display_all() method under each of the palettes and gradients modules, which displays a summary of all of the available colormaps within each module, as per #16.
a reversed() method for Gradients, as per #17.
automatic registration of reversed gradients into matplotlib's list of color gradients, with the suffix _r, as is conventional for matplotlib
a resample() method for Gradients, which returns a Palette with a resampled list of colors from the original Gradient, allowing users to use Gradient colors for a categorical plotting purpose, as requested in #4.
an interpolate() method for Gradients, which returns an updated Gradient with the values of colors adjusted so that they have uniformly increasing lightness in CAM02-UCS colorspace, addressing part of #17.
Testing
I confirmed that these functions work using usage_example.ipynb, where you can also see how these methods are meant to be used.
Not addressed
We are still finalizing the gradients, palettes, and font sizes, etc.; those changes will come in a future PR, including better names for unidirectional and bidirectional gradients. We're also working on making sure we have standardized sizing/ naming for plot sizes which can be drag/drop placed into Illustrator templates.
I also have not written tests for the mpl module or this new functionality yet... would love some help to do this if anyone has bandwidth.
Halp
Would love feedback on the naming and structure of things! I think we can be generally afford to be more verbose / less intuitive with some of the cvd stuff, since it's meant to be used primarily by color-obsessives like myself and Audrey.
PR checklist
Fixes #123, Resolves #456
).Overview
This PR adds functionality for simulating color vision deficiency under the
cvd
module.HexCode
objects), palettes, and gradients undercvd.simulate_color
,cvd.simulate_palette
, andcvd.simulate_gradient
. These methods return a transformed version of the color.cvd.simulate_color_all
,cvd_simulate_palette_all
, andcvd.simulate_gradient_all
. These methods returnNone
but display all 4 color spaces (normal, d, p, and t).cvd.simulate_gradient_lightness()
to display gradient lightness for all three major types of color vision deficiency.In addition, this PR adds some helpful utilities to the
Palette
andGradient
classes:swatch()
method forPalette
, which displays all the colors in the palette as a single strip of swatches prior to the specific color swatches, which has parallel functionality to theswatch()
method forGradient
..display_all()
method under each of thepalettes
andgradients
modules, which displays a summary of all of the available colormaps within each module, as per #16.reversed()
method forGradient
s, as per #17.matplotlib
's list of color gradients, with the suffix_r
, as is conventional formatplotlib
resample()
method forGradient
s, which returns aPalette
with a resampled list of colors from the originalGradient
, allowing users to useGradient
colors for a categorical plotting purpose, as requested in #4.interpolate()
method forGradient
s, which returns an updatedGradient
with the values of colors adjusted so that they have uniformly increasing lightness inCAM02-UCS
colorspace, addressing part of #17.Testing
I confirmed that these functions work using
usage_example.ipynb
, where you can also see how these methods are meant to be used.Not addressed
We are still finalizing the gradients, palettes, and font sizes, etc.; those changes will come in a future PR, including better names for unidirectional and bidirectional gradients. We're also working on making sure we have standardized sizing/ naming for plot sizes which can be drag/drop placed into Illustrator templates.
I also have not written tests for the
mpl
module or this new functionality yet... would love some help to do this if anyone has bandwidth.Halp
Would love feedback on the naming and structure of things! I think we can be generally afford to be more verbose / less intuitive with some of the
cvd
stuff, since it's meant to be used primarily by color-obsessives like myself and Audrey.