Search code examples
pythonmatplotlibplotcolorsaccessibility

How to make matplotlib markers colorblind-friendly in a simple way?


Currently I'm using command

plt.errorbar(X,Y,yerr=myYerr, fmt="o", alpha=0.5,capsize=4)

and I get default marker colours:

enter image description here

But what should I do to force matplotlib to be more colorblind-friendly?


Solution

  • According to this [1] you can use the predefined colorblind style. It should be as simple as:

    import matplotlib.pyplot as plt
    plt.style.use('tableau-colorblind10')
    

    [1] https://matplotlib.org/stable/users/prev_whats_new/whats_new_2.2.html#new-style-colorblind-friendly-color-cycle

    Check out the last image from this link as well:

    https://matplotlib.org/stable/gallery/style_sheets/style_sheets_reference.html