question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[SchemaValidationError] 'selection' was unexpected

See original GitHub issue

Hi,

I am following a Google Colab which uses altair for visualization.

I don’t plan to use interactive notebook, so I am using altair-viewer for rendering via Python terminal. Unfortunately, I run into following exception:

    raise SchemaValidationError(self, err)
altair.utils.schemapi.SchemaValidationError: Invalid specification

        altair.vegalite.v4.schema.channels.Color, validating 'additionalProperties'

        Additional properties are not allowed ('selection' was unexpected)

Here is my sample code (same as one found on colab):

import altair as alt

alt.data_transformers.enable('default', max_rows=None)
alt.renderers.enable('altair_viewer')

# Load data (skipped for brevity)

occupation_filter = alt.selection_multi(fields=["occupation"])
occupation_chart = alt.Chart().mark_bar().encode(
        x="count()",
        y=alt.Y("occupation:N"),
        color=alt.condition(
            occupation_filter,
            alt.Color("occupation:N", scale=alt.Scale(scheme='category20')),
            alt.value("lightgray")),
    ).properties(width=300, height=300, selection=occupation_filter)

# Explicitly call show
occupation_chart.show()

I have tried both pip install altair and pip install git+git://github.com/altair-viz/altair.git

Following example from altair doc seems to work fine from terminal:

>>> import altair as alt
>>> 
>>> # load a simple dataset as a pandas DataFrame
... from vega_datasets import data
>>> cars = data.cars()
>>> chart = alt.Chart(cars).mark_point().encode(
...     x='Horsepower',
...     y='Miles_per_Gallon',
...     color='Origin',
... ).interactive()
>>> chart.show()
Displaying chart at http://localhost:21098/

Please guide how to unblock myself. Apologies if this is a noob question, my first time trying altair.

Thank you!!!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:13 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
jakevdpcommented, Jul 29, 2020

Does it open up charts at your end?

Does what open up charts? None of your code includes the data, so I cannot run it. Try to create a short, complete snippet, with no reference to data files on your computer, that I can copy and paste into a terminal to see the error you’re seeing.

1reaction
jakevdpcommented, Jul 27, 2020

I can’t run your code, because your data does not exist on my system. Can you create a minimal example that reproduces the error?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Altair SchemaValidationError: Invalid specification
Row, validating 'additionalProperties' Additional properties are not allowed ('axis' was unexpected) alt.VConcatChart(...) concatenation ...
Read more >
debugging schema validation issues - how to?
I am using Altair 4.1.0. In calling chart.save('foo.html') I get a schema validation error. The actual message was not that informative to me.....
Read more >
Schema Validation error (type mismatch)-Custom Connector
Hi, Thank you for your time. I'm working with custom connector created from postman collection, but it is throwing below error. Property.
Read more >
Unexpected schema validation error received using ...
When sending a request to a DataPower service that is defined with the XML or Non-XML request type, an unexpected schema validation error...
Read more >
Handling Validation Errors - python-jsonschema
Iterable) – the errors to select from. Do not provide a mixture of errors from different validation attempts (i.e. from different instances or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found