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

Skip to content

Add aggregate support #32

Open
Open
@kdorr

Description

@kdorr

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

Code for reproduction

data:

df = pd.DataFrame({
    'a': [1, 1, 2, 3],
    'b': [1.1, 2.2, 3.3, 4.4]
})

Example 1:

chart = alt.Chart(df).mark_point().encode(
    alt.X('a'), alt.Y('average(b)')
)
mplaltair.convert(chart)

Example 2:

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 should work.

The first chart should look something like this:

aggregates_altair

The second chart should look something like this:

aggregates_altair_count

Possible solution

During the initial altair chart parsing, manipulate the data to include the aggregations. See parse_chart.ChannelMetadata() (specifically _aggregate_channel()).

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