matplotlib / matplotlib/mpl-altair

Categorical scatter plot

Open
#31 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
18
Forks
7
PR merge metrics
No merged PRs in 30d

Description

mpl-altair currently doesn't convert Altair charts that have categorical color, stroke, shape, or size encodings.

Code for reproduction

df = pd.DataFrame({
    'a': [1, 2, 3, 4], 'b': [7, 6, 5, 4], 'c': ['a', 'b', 'b', 'c']
})

chart = alt.Chart(df).mark_point().encode(
    alt.X('a'), alt.Y('b'), alt.Color('c:N')
)
mplaltair.convert(chart)

Actual outcome

A NotImplementedError is raised.

Expected outcome

Something that looks kind of like this:

scatter_altair

Possible solutions

  • Fix this on the Matplotlib side of things
  • Incorporate a workaround similar to how mplaltair._marks._handle_line() deals with colors in line plots

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

Run the Python reproduction first to confirm that categorical color encoding raises NotImplementedError. Then inspect mplaltair._marks._handle_line() and the conversion path for point marks, using the expected scatter plot as the completion criterion; verify that categorical color, stroke, shape, and size encodings no longer fail.

Written by the indexing model from the issue text.

Assessment

Tech stack
matplotlib, python
Domain
data-visualization
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.