matplotlib / matplotlib/mpl-altair
Add binning 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 binning.
Code for reproduction
from vega_datasets import data
seattle = data.seattle_weather()
seattle.head()
Binning color in a scatter plot:
chart = alt.Chart(seattle).mark_point().encode(
alt.X('wind'), alt.Y('temp_max'), alt.Color('temp_min', bin=alt.Bin(step=10))
)
mplaltair.convert(chart)
Binning in a bar chart:
chart = alt.Chart(seattle).mark_bar().encode(
alt.X('wind', bin=True), alt.Y('count()')
)
mplaltair.convert(chart)
Actual outcome
In a chart that would work without binning, binning fails silently and the chart is converted as if binning is always false.
Binning color in a scatter plot:

Binning in a bar chart:
raises NotImplementedError until bar charts and aggregates are working.
Expected outcome
Converting a scatter plot with binned color should produce a chart that looks something like this:

Converting a binned bar chart should produce a chart that looks something like this:

Possible solution and notes
- Manipulate the data to be binned in
parse_chart.ChannelMetadata(). - Binning is probably better to add when bar charts and aggregate functions are functional in mplaltair.
- Be aware that binning can happen in the encoding definition or in a transform.
For more info
- Altair's user guide on binning
- Vega-Lite documentation on binning
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() and reproduce the scatter and bar chart examples from the issue. Check how binning is represented in encoding definitions and transforms, then verify that binned color and binned bar charts produce the expected results once the relevant bar-chart and aggregate support is available.
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