{"id":17313124,"url":"https://github.com/mpetroff/accessible-color-cycles","last_synced_at":"2025-04-14T14:15:40.031Z","repository":{"id":56775866,"uuid":"367448269","full_name":"mpetroff/accessible-color-cycles","owner":"mpetroff","description":null,"archived":false,"fork":false,"pushed_at":"2024-01-06T21:07:57.000Z","size":62870,"stargazers_count":39,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-14T14:15:29.157Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://arxiv.org/abs/2107.02270","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mpetroff.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-05-14T18:26:06.000Z","updated_at":"2025-03-19T18:12:27.000Z","dependencies_parsed_at":"2024-11-08T05:12:44.556Z","dependency_job_id":null,"html_url":"https://github.com/mpetroff/accessible-color-cycles","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpetroff%2Faccessible-color-cycles","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpetroff%2Faccessible-color-cycles/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpetroff%2Faccessible-color-cycles/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpetroff%2Faccessible-color-cycles/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mpetroff","download_url":"https://codeload.github.com/mpetroff/accessible-color-cycles/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248894943,"owners_count":21179153,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-15T12:45:50.294Z","updated_at":"2025-04-14T14:15:40.007Z","avatar_url":"https://github.com/mpetroff.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Creating accessible color cycles for data visualization\n\n[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.5806615.svg)](https://doi.org/10.5281/zenodo.5806615)\n[![arXiv](https://img.shields.io/badge/arXiv-2107.02270-red)](https://arxiv.org/abs/2107.02270)\n\nThis code serves as a supplement to the paper titled _Accessible Color Sequences for Data Visualization_. It contains code for creating random color sets with a minimum perceptual distance enforced, for running a color-cycle aesthetic-preference survey, for creating a machine-learning aesthetic-preference model based on the survey results, and for creating final color cycles that balance accessibility with aesthetics. Additionally, it includes data resulting from the survey and the analysis.\n\nThe analysis was performed under Ubuntu 18.04 on a dual-socket system with Intel Xeon E5-2690 v4 CPUs and a Python 3.6.9 virtual environment defined by the `requirements.txt` file (installed with `pip==21.1.1`, `setuptools==56.2.0`, `wheel==0.36.2`).\n\nNotebooks were executed with:\n```\n$ jupyter nbconvert --ExecutePreprocessor.timeout=-1 --ExecutePreprocessor.record_timing=False --to notebook --execute notebook.ipynb\n```\n\n## Final results\n\nThe final results of the present analysis are located in the `aesthetic-models/top-cycles.json` file. The top six-color color cycle is:\n```\n[\"#5790fc\", \"#f89c20\", \"#e42536\", \"#964a8b\", \"#9c9ca1\", \"#7a21dd\"]\n```\nThe top eight-color color cycle is:\n```\n[\"#1845fb\", \"#ff5e02\", \"#c91f16\", \"#c849a9\", \"#adad7d\", \"#86c8dd\", \"#578dff\", \"#656364\"]\n```\nThe top ten-color color cycle is:\n```\n[\"#3f90da\", \"#ffa90e\", \"#bd1f01\", \"#94a4a2\", \"#832db6\", \"#a96b59\", \"#e76300\", \"#b9ac70\", \"#717581\", \"#92dadd\"]\n```\n\n\n## Analysis steps\n\n### Color-set generation\n\nThe `set-generation` directory contains scripts for generating color sets. The `gen_color_sets.py` script generates random color sets with perceptual-distance constraints. The sets used for the color-cycle survey can be regenerated with:\n```\n$ python3 gen_color_sets.py --num-colors 6 --min-light-dist 2 --min-color-dist 20 --include-bug\n$ python3 gen_color_sets.py --num-colors 8 --min-light-dist 2 --min-color-dist 18 --include-bug\n$ python3 gen_color_sets.py --num-colors 10 --min-light-dist 2 --min-color-dist 16 --include-bug\n```\nThe final color sets can be regenerated with:\n```\n$ python3 gen_color_sets.py --num-colors 6 --min-light-dist 5.0 --min-color-dist 20 --max-j 80\n$ python3 gen_color_sets.py --num-colors 8 --min-light-dist 4.2 --min-color-dist 18 --max-j 82\n$ python3 gen_color_sets.py --num-colors 10 --min-light-dist 3.6 --min-color-dist 16 --max-j 84\n```\nRegenerating the color sets requires several thousand CPU hours. The `--include-bug` flag forces the script to include a bug that was present when the color sets used for the survey were generated, which affected how uniformly the color gamut was sampled.\n\nThe `max_dist_seq.py` script generates color cycles using the sequential-search method of Glasbey et al. (2007) extended to use CAM02-UCS and color-vision-deficiency simulations. The contents of Table 1 of the paper can be regenerated with:\n```\n$ python3 max_dist_seq.py --min-j 0 --max-j 100\n$ python3 max_dist_seq.py --min-j 40 --max-j 90\n```\nThis process is single-threaded, requires \u003e60GB of memory, and takes a day or two.\n\n\n### Color-cycle survey\n\nThe `survey` directory contains the code used to run the color-cycle survey. The `to_hcl.py` script was used to sort the color sets generated in the previous step by hue, then chroma, then lightness to be used for the survey. The `main.go` file contains the server backend code, which records survey responses to a text-based log file. The static files for the survey's frontend can be regenerated using `npm run build`.\n\n\n### Color-cycle survey results\n\nThe `survey-results` directory contains the results of the color-cycle survey. The `parse-log.ipynb` notebook contains the code used to parse the survey results log file and contains summary statistics of the survey user sessions. The `results.db` SQLite database, which was created by the previously-mentioned notebook, contains the survey responses. To protect the privacy of the survey respondents, neither the log file used to create the results database nor the database's sessions table are included in this data release. Country codes were derived from partial IP addresses using the [2019-12-24 release](https://web.archive.org/web/20191227182412/https://geolite.maxmind.com/download/geoip/database/GeoLite2-Country.tar.gz) of the MaxMind GeoLite2 Country geolocation database. The SHA-256 hashes of the `results.log` and `GeoLite2-Country_20191224.mmdb` files (which are not included in this repository) are `4f4519dfb17e0cb459bb4f16d1656d46d893d56304c5ef7c136d81d851088cc8` and `9aedbe59990318581ec5d880716d3415e40bfc07280107112d6d7328c771e059`, respectively.\n\n\n### Validation survey\n\nThe `validation-survey` directory contains the code used to run the validation survey, which was slightly tweaked from the main color-cycle survey code. The `main.go` file contains the server backend code, which records survey responses to a text-based log file. The static files for the survey's frontend can be regenerated using `npm run build`.\n\n\n### Validation survey results\n\nThe `validation-survey-results` directory contains the results of the validation survey. The `parse-log.ipynb` notebook contains the code used to parse the survey results log file and contains summary statistics of the survey user sessions. The `results.db` SQLite database, which was created by the previously-mentioned notebook, contains the survey responses.\n\n\n### Probabilistic color-name model\n\nThe `color-name-model` directory contains a reanalysis of the probabilistic color-name model described in Heer \u0026 Stone (2012). The `post-process-heer-stone.ipynb` notebook contains this analysis, which finds and merges synonymous color names and eliminates rarely-used color names. The `colornamemodel.npz` file contains the data of the post-processed model.\n\n\n### Machine-learning aesthetic-preference models\n\nThe `aesthetic-models` directory contains the code and weights used to create and evaluate machine-learning models for aesthetic preference of color sets and cycles. The `set-analysis.ipynb` notebook contains the code used to create and train the color set model, while the `set-evaluation.ipynb` contains the code used to evaluate it. The `cycle-analysis.ipynb` notebook contains the code used to create and train the color cycle model, while the `cycle-evaluation.ipynb` notebook contains the code used to evaluate it. The `weights` subdirectory contains the model weights for both models. The `numpy-version` subdirectory contains a script for converting the weights from the TensorFlow format to a NumPy-compatible format and an example implementation for evaluating the model in NumPy, without the need for TensorFlow. The `set-scores.npz` file contains the scores for each of the input color sets, while the `top-sets.json` file contains the color sets with the highest scores. The `cycle-scores.npz` file contains the scores for each ordering of the color sets with the highest scores, and the `top-cycles.json` file contains the color cycles with the highest scores, which are the final results of the present analysis. The `additional-evaluation.ipynb` notebook looks at the various score ranges.\n\nNote that the v1.0 release had a data loading bug, which affected the cycle model. Although it affected the model accuracy, it did not affect the final color cycles. The original model should not be used.\n\n\n### Other analysis\n\nThe `other-analysis` directory contains code for performing other analyses on the data. The `max-min-dists.ipynb` notebook contains code for finding the color sets with the maximum minimum-perceptual distances, and the `min-max-dist-sets.json` file contains the results of this analysis. The `set-analysis-linear-model.ipynb` notebook contains an analysis of the survey responses based on a linear model. The `result-plots.ipynb` notebook generates the tables and plots for this repository's companion paper. The `compare-pair-preference-scores.ipynb` notebook evaluates the effectiveness of the aesthetic pair-preference model described in Gramazio et al. (2017) on the survey data. The notebook can be executed from the `src` directory of [Colorgorical](https://github.com/connorgr/colorgorical) using Git commit 90649656a57ce9743b00390473adce51a821cadc. Unfortunately, the Colorgorical repository does not include licensing information. The `cycle-comparison.ipynb` notebook evaluates the accessibility of a variety of existing color cycles and compiles the results into a table. The `linear-ml-set-comparison.ipynb` notebooks does a statistical comparison of the accuracies of the linear model and machine learning model for sets.\n\n\n### Lightness analysis\n\nThe `lightness-analysis` directory contains a reanalysis of the scatter plot accessibility data collected by Smart \u0026 Szafir (2019). The `lightness-analysis.ipynb` notebook contains the code used to perform this analysis, which looks at how scatter-plot-marker lightness affects response times. The [color-shape_data_processed.csv](https://osf.io/nz2y7/) file has a SHA-256 hash of `c0fe510d1b673d26a9fa1085fc5da3017b27cc3814c6e587a1800a7a647c778d` but is not included in this repository as it was not distributed with explicit licensing information.\n\n\n\n## Changelog\n\n### v2.0\n\n* Added validation survey and results\n* Fixed data loading bug in cycle model: this affected the model but did not affect the final cycles\n* Added evaluation of score ranges\n* Added statistical comparison of linear model and machine learning model for sets\n* Moved NumPy model out of notebook\n\n### v1.0\n\n* Initial release.\n\n\n\n## License\n\nThe code contained in this repository is distributed under the [MIT License](https://opensource.org/licenses/MIT).\n\nThe included color-vision-deficiency simulation and color-distance calculation implementations (`set-generation/color_conversions.py`) are based on [Colorspacious](https://github.com/njsmith/colorspacious), which is [MIT licensed](https://github.com/njsmith/colorspacious/blob/v1.1.0/LICENSE.txt).\n\nThe `color-name-model/c3_data.json` file is from [C3 (Categorical Color Components)](https://github.com/StanfordHCI/c3/blob/d3576c7615ab0d6b2d81252a362599a9fd900d63/data/xkcd/c3_data.json), which is distributed under a [3-Clause BSD License](https://github.com/StanfordHCI/c3/blob/d3576c7615ab0d6b2d81252a362599a9fd900d63/LICENSE).\n\nThe resulting data files (including, but not limited to, the final color cycles and the `survey-results/results.db` file) are released into the public domain using the [CC0 1.0 Public Domain Dedication](https://creativecommons.org/publicdomain/zero/1.0/).\n\n\n\n## Credits\n\nThis code was written by Matthew A. Petroff ([ORCID:0000-0002-4436-4215](https://orcid.org/0000-0002-4436-4215)).\n\nThe included scatter plot lightness analysis is based on data collected by:\n\u003e Stephen Smart and Danielle Albers Szafir. 2019. Measuring the Separability of Shape, Size, and Color in Scatterplots. In _Proceedings of the 2019 CHI Conference on Human Factors in Computing Systems (CHI '19)_. ACM Press, New York, 14 pages. [doi:10.1145/3290605.3300899](https://doi.org/10.1145/3290605.3300899)\n\nThe included color naming model is based on work by:\n\u003e Jeffrey Heer and Maureen Stone. 2012. Color naming models for color selection, image editing and palette design. In _Proceedings of the SIGCHI Conference on Human Factors in Computing Systems_ (Austin, Texas) _(CHI '12)_. ACM Press, New York, 1007--1016. [doi:10.1145/2207676.2208547](https://doi.org/10.1145/2207676.2208547)\n\nwhich used data collected by Randall Munroe's [xkcd color survey](https://blog.xkcd.com/2010/05/03/color-survey-results/).\n\nA comparison is made to a pair-preference model developed by:\n\u003e Connor C. Gramazio, David H. Laidlaw, and Karen B. Schloss. 2017. Colorgorical: Creating discriminable and preferable color palettes for information visualization. _IEEE Transactions on Visualization and Computer Graphics_ 23, 1 (Jan. 2017), 521--530. [doi:10.1109/tvcg.2016.2598918](https://doi.org/10.1109/tvcg.2016.2598918)\n\nThe color-vision-deficiency simulation is based on:\n\u003e Gustavo M. Machado, Manuel M. Oliveira, and Leandro A. F. Fernandes. 2009. A Physiologically-based Model for Simulation of Color Vision Deficiency. _IEEE Transactions on Visualization and Computer Graphics_ 15, 6 (Nov. 2009), 1291--1298. [doi:10.1109/tvcg.2009.113](https://doi.org/10.1109/tvcg.2009.113)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmpetroff%2Faccessible-color-cycles","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmpetroff%2Faccessible-color-cycles","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmpetroff%2Faccessible-color-cycles/lists"}