matplotlib / matplotlib/matplotlib

[Bug]: axes.prop_cycle behavior change

Open
#29,915 6 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
23.2k
Forks
8.5k
Avg merge
1d 6h
Merged PRs (30d)
66

Description

PR #29808 (identified by `git bisect`) changed the behavior of:
```
$ python -c 'import matplotlib; print(matplotlib.rcParams.get("axes.prop_cycle").by_key()["color"])'
['#1f77b4', '#ff7f0e', '#2ca02c', '#d62728', '#9467bd', '#8c564b', '#e377c2', '#7f7f7f', '#bcbd22', '#17becf']
```
to now be a list of tuple of float rather than a list of str:
```
$ python -c 'import matplotlib; print(matplotlib.rcParams.get("axes.prop_cycle").by_key()["color"])'
[(0.12156862745098039, 0.4666666666666667, 0.7058823529411765), (1.0, 0.4980392156862745, 0.054901960784313725), (0.17254901960784313, 0.6274509803921569, 0.17254901960784313), (0.8392156862745098, 0.15294117647058825, 0.1568627450980392), (0.5803921568627451, 0.403921568627451, 0.7411764705882353), (0.5490196078431373, 0.33725490196078434, 0.29411764705882354), (0.8901960784313725, 0.4666666666666667, 0.7607843137254902), (0.4980392156862745, 0.4980392156862745, 0.4980392156862745), (0.7372549019607844, 0.7411764705882353, 0.13333333333333333), (0.09019607843137255, 0.7450980392156863, 0.8117647058823529)]
```
This is potentially problematic for end-users. MNE-Python we know the default `prop_cycle` (and everyone seems to use it!) so make use of the fact that we know `#7f7f7f` is in there, remove it, and create a new cycle. Our code now breaks with:
```
self.color_list.remove("#7f7f7f")
ValueError: list.remove(x): x not in list
```
And yes we should make our check better (e.g., remove any color sufficiently close to the bad color, etc.) but it seems like a potential regression that this behavior has changed in any case. Feel free to close if not!

Contributor guide

Open the contributing guide

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

Reproduce the two Python commands for rcParams.get("axes.prop_cycle").by_key()["color"] and inspect PR #29808, identified by git bisect, to trace the representation change. Compare the current and prior behavior, then add regression coverage for the expected public value and verify that the axes property cycle remains usable by downstream code.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data-visualization
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 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.