Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add binning support #28

Open
kdorr opened this issue Aug 16, 2018 · 0 comments
Open

Add binning support #28

kdorr opened this issue Aug 16, 2018 · 0 comments
Labels
enhancement New feature or request

Comments

@kdorr
Copy link
Collaborator

kdorr commented Aug 16, 2018

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

@kdorr kdorr added the enhancement New feature or request label Aug 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant