Giter VIP home page Giter VIP logo

colourblind8's Introduction

Colourblind8

Build Status

A python package that creates colourblind friendly plots.

Authors

Ian Flores Sabrina Tse Hayley Boyce

Project

Overview

Colourblind8 is a brand new plotting package implemented for matplotlib to optimize graphs into a format interpretable by people with colourblindness. Colourblindness, also known as colour vision deficiency, is a condition that affects individuals how they perceive colours visually. According to colourblindawareness.org, colourblindness affects 1 in every 12 men and 1 in every 200 women globally. This package is inspired by the fact that people without knowledge about this condition don't know how to make their graphs accessible. Our objective is to enhance data visualization by implementing proper colours so that the graphs are perceived correctly by all readers as intended.

Scope

At this stage, Colourblind8 will focus on developing settings for the three most prevalent colourblind perspectives - protanopia, deuteranopia and tritanopia (see Appendix for more information on the types of colourblindness).

Function Description

In this package, three functions are included to make matplotlibplots more interpretable for people with protanopia, deuteranopia and tritanopia. Within each function, users can select one of our customized colour palettes via the palette argument according to their preference: deutera for deuteranopia,prota for protanopia ,tritafor tritanopia. The following are our main functions:

  • plot_lines(x, y, alpha = 1.0, labels = None, palette = None, title = None, x_lab = None, y_lab = None, legend_title = None):

    • This function implements a method that creates line graphs by initializing the colour of lines, the face colour of the chart, the transparency of objects, and the font size for title, legend and axes.

    Inputs: x variable, y variable (a list of lists), transparency, labels of each y variable, palette colour, title, x labels, y labels and legend title.
    Output: a matplotlib line graph object.

  • plot_scatter(x, y, alpha = 1.0, labels = None, palette = None, title = None, x_lab = None, y_lab = None, legend_title = None):

    • This function implements a method that creates scatterplots by initializing the colour of data points, the face colour of the chart, the transparency of objects, and the font size for title, legend and axes.

    Inputs: x variable, y variable (a list of lists), transparency, labels of each y variable, palette colour, title, x labels, y labels and legend title.
    Output: a matplotlib scatterplot object.

  • plot_histogram(y, alpha = 1.0, bins = None, labels = None, palette = None ,title = None, x_lab = None, legend_title = None):

    • This functions implements a method that enhances histograms through modifying the colour of histogram layers, the face colour of the chart, the transparency of objects,bin size and the font size for title, legend and axes.

    Inputs: y variable (a list of lists), transparency, bin size, labels of each y variable, palette colour, title, x labels, y labels and legend title.
    Output: a matplotlib histogram object.

For more details, please use the following commands:

help(Colourblind8) for class docstring

help(Colourblind8.modulename) for module docstring

Installation

To install Colourblind8 via pip, please input the following into the Terminal:

pip install git+https://github.com/UBC-MDS/Colourblind8.git

To upgrade to the latest version, use:

pip install -- upgrade git+https://github.com/UBC-MDS/Colourblind8.git

Usage

Please note, for a more clear execution of our package, Varada Kolhatkar (UBC MDS instructor) suggested an additional document (jupyter notebook) to demonstrate how to use our package with a test dataset, along with our tests being passed. She found this a more beneficial method of visually comparing the output with the test cases.

The demonstration can be found in the example folder of this repository named sample_usage.ipynb.

Step by step guide
  1. Since Colourblind8 is built on matplotlib, it is necessary to import matplotlib, as well as Colourblind8. Don't forget to initialize Colourblind8 before using.
import matplotlib.pyplot as plt
from colourblind8.colourblind8 import Colourblind8()
  1. Select one of the available Colourblind8 graphs and one of our customized colour palettes for data visualization. We picked plot_lines() and palette = "trita" as an example:
cb = Colourblind8()
cb.plot_lines(x, y, alpha = 1.0, labels = None, palette = "trita", title = None, x_lab = None, y_lab = None, legend_title = None)

Three colour palettes are available : deutera,prota,trita

Sample Graphs

Line Graph:

Input

data:

x=[1,2,3,4]

y_list=[[1,2,3,4],[3,5,7,9],[4,7,5,9],[1,4,6,8],[4,6,7,9],[1,3,4,8],[0,4,7,2],[-1,4,7,-7],[9,7,5,3]]
cb=Colourblind8()
cb.plot_lines(x, y_list, alpha =1.0, labels =['a','b','c','d','e','f','g','h','i'], palette = 'trita', title = "Trita Line Example", x_lab = "X label",  y_lab = "Y label", legend_title = "Legend")
Output (colour palettes' presentation)
deutera Prota Trita

Scatterplot Graph

Input

data:

N = 10
x = np.random.rand(N )
y_1 = np.random.rand(N)
y_2 = np.random.rand(N)
y_3 = np.random.rand(N)
y_4 = np.random.rand(N)
y_5 = np.random.rand(N)
y_6 = np.random.rand(N)
y_7 = np.random.rand(N)
y_8 = np.random.rand(N)
y_9 = np.random.rand(N)

y_list= []
for i in range(9):
    y = np.random.rand(N)
    y_list.append(y)
cb = Colourblind8()
cb.plot_scatter(x, y_list, alpha =1.0, labels =['a','b','c','d','e','f','g','h','i'], palette = 'deutera', title = "Deutera scatterplot Example", x_lab = "X label",  y_lab = "Y label", legend_title = "Legend" )
Output (colour palettes' presentation)
deutera Prota Trita

Histogram Graph

Input

data:

N = 100
x = np.random.rand(N)
y = np.random.rand(N)
z = np.random.rand(N)
list_y = [x,y,z]
cb = Colourblind8()
cb.plot_histogram(y = list_y, palette= 'prota', x_lab=' X Label', title = 'Deutera Histogram Example', alpha = 0.5, bins =10, labels=['c', 'b', "c"], legend_title="legend")
Output (colour palettes' presentation)
deutera Prota Trita

Control Flow Diagram

As we are committed to support open source, we provide the complete Colourblind8 Control Flow Diagram for each function from our package for users who are interested in the backend workflow.

plot_lines() Control Flow Diagram plot_scatter() Control Flow Diagram plot_histogram() Control Flow Diagram

Branch Coverage Testing

(waiting for instructor's response on whether to use coverage.py or manual test)

Control Flow Diagram

As we are committed to support open source, we provide the complete Colourblind8 Control Flow Diagram for each function in our package for users who are interested in the backend workflow they can be found in the branch_coverage folder.

Branch Coverage Testing

In total, 6 tests were identified for our initial manual testing. We pass all 6 tests for each function and a screenshot in the img file named tests_results.png is available for your convenience.

Our Package in the Python Ecosystem

To the best of our knowledge, there is currently no other colourblind specific package available for matplotlib that offers colourblind-friendly palettes or themes. Seaborn, in conjunction with matplotlib, offers a single default colour palette (source) named colorblind targeting readers with general colourblindness and does not accommodate different variants of colourblind conditions.

Colourblind8 will bridge the gap as it attempts to fit into the Python ecosystem by offering a convenient and effective way to give all matplotlib visualizations a theme and fully inclusive colour palette. A package that shows a similar contribution to the python ecosystem is daltonize. This package aids to creating all images colourblind friendly as opposed to Colourblind8 which will make specifically data visualizations, plots and graphs fully inclusive for all readers.

Appendix

Protanopia

Protanopes are more likely to confuse:-

  1. Black with many shades of red
  2. Dark brown with dark green, dark orange and dark red
  3. Some blues with some reds, purples and dark pinks
  4. Mid-greens with some oranges

Deuteranopes

Deuteranopes are more likely to confuse:-

  1. Mid-reds with mid-greens
  2. Blue-greens with grey and mid-pinks
  3. Bright greens with yellows
  4. Pale pinks with light grey
  5. Mid-reds with mid-brown
  6. Light blues with lilac

Tritanopes

The most common colour confusions for tritanopes are light blues with greys, dark purples with black, mid-greens with blues and oranges with reds.

source:http://www.colourblindawareness.org/colour-blindness/types-of-colour-blindness/


colourblind8's People

Contributors

hfboyce avatar ian-flores avatar sabrinatkk avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

colourblind8's Issues

Feedback on Milestone #1

Good work team! Your package is set up and organized quite nicely. I noticed your Issue regarding implementing roxygen, thanks for clarifying that.

The primary worry I have with your project is that you only have one test case that will be applied to all three of your functions. One of the primary goals of this milestone (and of the class!) is to experiment and become familiar with different types of tests. Is there a way that you could implement a greater variety of tests to your functions? Perhaps this will become clearer once you start to write the functions.

You also don't include any tests for checking the inputs and outputs of your functions. I understand that this might not completely applicable, since your functions are just themes, but you could at least check to see if what you are creating is compatible with different types of ggplot2/matplotlib objects.

Fix Tests

Feedback from Rainer explained we should test input and outputs of our functions.

  • Add input and output Tests
  • implement a greater variety of tests to functions - (How? let's discuss)
  • Documentation

Feedback on Project Proposal

Great job team! Very interesting concept, I'm a little surprised this doesn't exist yet! I also appreciate the included appendix. A few comments:

  1. It would be good if you could more specifically define which changes to color schemes you intend to make with all three functions. Will you attempt to accommodate all of the points outlined in the appendix? If so fantastic! But if that is a bit too complicated/time consuming please let us know. This assignment shouldn't be too complicated to implement test cases.
  2. It might also be a good idea to define exactly how many colors each function can support. Again, this could help limit the complexity of your functions.
  3. It would be great to have a little more detail on how exactly these functions will modify the layout of the plots.
  4. Will these functions be used with a specific python plotting package, e.g. matplotlib? Or do you intend for this to work generally for all python plots?

Feedback on Milestone #2

Good work team! You've done a great job organizing and building your repo. A few comments:

  • Nice work using branches and issues with your workflow
  • All tests path except for one passed. The test that failed (test_input located in test_histogram.py) spat out this error when I used pytest: "fixture 'y' not found". Did you also receive this error? It may have been due to how my personal python environment is set up.
  • Related to this issue, we are asking that for future versions of your functions you attach, in a new folder, a screenshot of your pytest output.
  • Good job with your documentation and commenting your functions. Your README is easily navigated and the examples of outputted graphs are helpful.
  • Is there a reason you put all of your functions in the same python script? As opposed to different scripts? I suppose it doesn't matter but it might make your package a little more readable to split it up.

Thanks for the good work!

To-Do List before Friday, 2019-02-12

To - Do list for Friday:

Research (please provide links and reference):

  • Colour Palette for each function # 10 max

    • Hayley : set_prota()
    • Ian: set_trita()
    • Sabrina: set_deutera()
  • How to change objects in matplotlib plots

  • How to implement a theme function in Python

Function Codes

  • Code Function theme for set_deutera()
  • Code Function theme for set_prota()
  • Code Function theme for set_trita()

Workflow and Readme Implementation

Starting from this milestone, you must follow the GitHub Flow workflow. Each team member must do at least one review and each member must have some part of their code reviewed by other team members.

  • Hayley
  • Sabrina
  • Ian

Python Readme Update

  • Installation
  • Usage

Functions Theme Design

  • Design Function theme for set_deutera()
  • Design Function theme for set_prota()
  • Design Function theme for set_trita()

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.