Automatically determine label color based on background color

Open
#1,013 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
python

Research direction

Start with the annotated heatmap example linked in the issue and trace how plotnine maps background colours and renders inline labels. Determine the legibility rule and where an automatic font-colour choice belongs; done means labels remain legible across mapped backgrounds without the dataframe workaround, with coverage for relevant cases.

Written by the indexing model from the issue text.

Description

Enhancement Feature

In plots with inline text (labels), the text must be legible at all times, this entails changing the font color based on the background color.

The current workaround also advertised in the docs is to insert a new column into the dataframe that directly maps the color based on some threshold.

Since plotnine is responsible for mapping background colors, it could compute the font color for labels ad-hoc based on the background color such that it is always legible.

This would make the library more ergonomic for me. Currently, I spend more time than I would like to admit manually adjusting the threshold.

Dominant language
Python
Stars
4.8k
Forks
269
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from has2k1/plotnine

All issues in has2k1/plotnine

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.