matplotlib / matplotlib/mpl-altair
Add aggregate support
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 support conversion for Altair charts that use aggregations.
**Code for reproduction**
data:
```python
df = pd.DataFrame({
'a': [1, 1, 2, 3],
'b': [1.1, 2.2, 3.3, 4.4]
})
```
Example 1:
```python
chart = alt.Chart(df).mark_point().encode(
alt.X('a'), alt.Y('average(b)')
)
mplaltair.convert(chart)
```
Example 2:
```python
chart = alt.Chart(df).mark_point().encode(
alt.X('a'), alt.Y('count()')
)
mplaltair.convert(chart)
```
**Actual outcome**
A `NotImplementedError` is raised for anything that has aggregated data.
**Expected outcome**
Any plot with [aggregation](https://altair-viz.github.io/user_guide/encoding.html#binning-and-aggregation) should work.
The first chart should look something like this:

The second chart should look something like this:

**Possible solution**
During the initial altair chart parsing, manipulate the data to include the aggregations. See `parse_chart.ChannelMetadata()` (specifically `_aggregate_channel()`).
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in parse_chart.ChannelMetadata(), particularly _aggregate_channel(), and reproduce the issue with the two Python chart examples using average(b) and count(). Trace how aggregated data is parsed and ensure both mplaltair.convert(chart) calls complete without NotImplementedError and produce the expected aggregate plots.
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
- 45/100