matplotlib / matplotlib/mpl-altair

Add timeUnit support

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

Nobody has claimed this yet.

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

Description

mpl-altair currently doesn't support conversion for Altair charts that use timeUnit aggregations.

Code for reproduction

This and other timeUnit transformations don't work:

from vega_datasets import data
seattle = data.seattle_weather()

chart = alt.Chart(seattle).mark_point().encode(
    alt.X('month(date)'), alt.Y('temp_max')
)
mplaltair.convert(chart)

Actual outcome

A NotImplementedError is raised for anything that has a timeUnit.

Expected outcome

Any plot with a timeUnit transformation should work.

This plot should look something like this:

timeunit_altair

Possible solution and notes

  • Manipulate the data in parse_chart.ChannelMetadata() so that the data reflects the timeUnit aggregation. (see parse_chart.ChannelMetadata._handle_timeUnit().)
  • Also note that timeUnit transformations can also be applied separately from timeUnit transformations in the encoding channel.

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 reproduction using the Seattle weather dataset and inspect parse_chart.ChannelMetadata(), especially _handle_timeUnit(), where the issue identifies the current limitation. Check how timeUnit is represented in channel encoding and how separate timeUnit transformations are handled. Done means the reproduction and other timeUnit transformations convert without NotImplementedError and produce the expected time-based plot.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.