moj-analytical-services / splink

Fast, accurate and scalable probabilistic data linkage with support for multiple SQL backends
https://moj-analytical-services.github.io/splink/
MIT License
1.33k stars 147 forks source link

[FEAT] Alternate chart colour schemes #1469

Open ADBond opened 1 year ago

ADBond commented 1 year ago

Is your proposal related to a problem?

Quite a few of our charts are using red-green scales, which is not great for colourblindness accessibility.

Describe the solution you'd like

Charts using other, more accessible, schemes that still convey the relevant information clearly - e.g. viridis (see https://github.com/moj-analytical-services/splink/issues/1437#issuecomment-1634924919), brewer,

Might also be nice to have a few options - a sensible default, maybe a couple of other options, and perhaps the option for custom user-specified schemes.

Describe alternatives you've considered

Additional context

Loosely related: #642.

samnlindsay commented 1 year ago

A thought that occurred while looking at #1578

[!NOTE] Just while I'm testing out the new alert blockquote feature, I wonder if the colour issue could be addressed by adding a property to the linker that toggles required accessibility adjustments. So something like linker.accessible_charts = True can be set and the charts contain something like

if linker.accessible_charts:
  chart_def[...][...]["color"]["scale"] = diverging_colours_accessible
else:
  chart_def[...][...]["color"]["scale"] = diverging_colours_default

Where the colour scales (and likewise any other formatting) can be stored centrally and imported

Given the vast array of charts, it's difficult to ensure consistency of style across the board, whether performing one-off changes or more crucially when attempting to provide multiple options to users.

Aside from the color scheme, various formatting choices can and probably should be standardised, with or without additional options:

RossKen commented 1 year ago

Good pair programming use case

RobinL commented 1 year ago

There is such a thing as a vega lite theme. I wonder whether it could be used to blanket apply some styles. (I've never tried it)

samnlindsay commented 1 year ago

https://github.com/vega/vega-themes

https://observablehq.com/@vega/vega-themes-demo

A demo of using a custom theme with altair is shown here:

theme defined here

import altair as alt
from ... import theme

alt.themes.register('splink_theme', theme)
alt.themes.enable('splink_theme')