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

Boxplot not working with MarkDef #2545

Closed
eeroel opened this issue Jan 9, 2022 · 3 comments · Fixed by #3266
Closed

Boxplot not working with MarkDef #2545

eeroel opened this issue Jan 9, 2022 · 3 comments · Fixed by #3266
Labels

Comments

@eeroel
Copy link

eeroel commented Jan 9, 2022

Hi,

I noticed that specifying a boxplot through MarkDef doesn't work, even though the docs state it should. Tested with Altair 4.2.0 and 4.1.0. Using mark_boxplot works OK for me.

Example:

import pandas as pd
df = pd.DataFrame({
    'foo': [1,1,2,2,2,2,3,4,4,5]
})

# works 
import altair as alt
alt.Chart(df).mark_boxplot().encode(y='foo')

# fails
import altair as alt
alt.Chart(df, mark=alt.MarkDef(type='boxplot')).encode(y='foo')

This fails with

SchemaValidationError: Invalid specification

        altair.vegalite.v4.schema.core.MarkDef->type, validating 'enum'

        'boxplot' is not one of ['arc', 'area', 'bar', 'image', 'line', 'point', 'rect', 'rule', 'text', 'tick', 'trail', 'circle', 'square', 'geoshape']
@eeroel eeroel added the bug label Jan 9, 2022
@jakevdp
Copy link
Collaborator

jakevdp commented Jan 9, 2022

Can you point to the incorrect documentation?

@eeroel
Copy link
Author

eeroel commented Jan 9, 2022

The generated docs from vega-lite https://altair-viz.github.io/user_guide/generated/core/altair.MarkDef.html
say:

This could a primitive mark type (one of "bar", "circle", "square", "tick", "line", "area", "point", "geoshape", "rule", and "text" ) or a composite mark type ( "boxplot", "errorband", "errorbar" )"

@joelostblom
Copy link
Contributor

Since a boxplot is a composite mark, you would need to use:

alt.Chart(df, mark=alt.CompositeMarkDef(type='boxplot')).encode(y='foo')

The docs for this are being updated in https://github.com/altair-viz/altair/pull/3266/files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants