Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add binning support #28

Open
Open
@kdorr

Description

@kdorr

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:

bin_mplaltair

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:

bin-altair

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

bin_altair_bar

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions