has2k1 / has2k1/plotnine

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.

Enhancement Feature
Dominant language
Python
Stars
4.8k
Forks
254
Avg merge
10h 35m
Merged PRs (30d)
9

Description

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.

Contributor guide

No contributing guide indexed for this repository

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.

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.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.