Latest version of altair seems to have broken LayeredChart()
See original GitHub issueI tried this code both on desktop Jupyter notebook and in Azure notebook. It used to work in both.
With appropriately defined pandas dataframe named ‘data’
c=LayeredChart(data) c+=Chart().mark_line(color='green').encode(x="x",y="y") c+=Chart().mark_line(color='blue').encode(x='x',y='y2') c
This produces the error:
AttributeErrorTraceback (most recent call last)
/home/nbuser/anaconda2_410/lib/python2.7/site-packages/IPython/core/formatters.pyc in __call__(self, obj)
913 method = get_real_method(obj, self.print_method)
914 if method is not None:
--> 915 method()
916 return True
917
/home/nbuser/anaconda2_410/lib/python2.7/site-packages/altair/v1/api.pyc in _ipython_display_(self)
443 from IPython.display import display
444 from vega import VegaLite
--> 445 display(VegaLite(self.to_dict(validate_columns=True)))
446
447 def display(self):
/home/nbuser/anaconda2_410/lib/python2.7/site-packages/altair/v1/api.pyc in to_dict(self, data, validate_columns)
287 The JSON specification of the chart object.
288 """
--> 289 dct = super(TopLevelMixin, self.clone()).to_dict(data=data, validate_columns=validate_columns)
290 dct['$schema'] = schema.vegalite_schema_url
291 return dct
/home/nbuser/anaconda2_410/lib/python2.7/site-packages/altair/v1/schema/_interface/jstraitlets.pyc in to_dict(self, **kwargs)
151 def to_dict(self, **kwargs):
152 """Output a (nested) dict encoding the contents of this instance"""
--> 153 self._finalize(**kwargs)
154 Visitor = self._converter_registry.get('to_dict', ToDict)
155 return Visitor().visit(self, **kwargs)
/home/nbuser/anaconda2_410/lib/python2.7/site-packages/altair/v1/api.pyc in _finalize(self, **kwargs)
503 # and the Chart allows it.
504 if validate_columns and self.validate_columns:
--> 505 self._validate_columns()
506
507 def _finalize_data(self):
/home/nbuser/anaconda2_410/lib/python2.7/site-packages/altair/v1/api.pyc in _validate_columns(self)
569 # Find columns with visual encodings
570 encoded_columns = set()
--> 571 encoding = self.encoding
572 if encoding is not jst.undefined:
573 for channel_name in encoding.channel_names:
AttributeError: 'LayeredChart' object has no attribute 'encoding'
Out[9]:
<traitlets.traitlets.LayeredChart at 0x7f6b1c605750>
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:12 (6 by maintainers)
Top Results From Across the Web
Altair Change Log — Altair 4.2.0 documentation
Update Vega-Lite to version 4.8.1; many new features and bug fixes from ... the facet() method can now be called directly on a...
Read more >Bountysource
Latest version of altair seems to have broken LayeredChart() ... Coming soon: A brand new website interface for an even better experience!
Read more >visualization - How to set width of text marks in vega-lite / altair ...
Chart().mark_text() function to display the text. The text though is multiple phrases and should be wrapped (with line breaks). How can this be ......
Read more >Altair GraphQL Client
Altair is a feature-rich GraphQL Client IDE for all platforms. Enables you interact with any GraphQL server you are authorized to access from...
Read more >Altair heatmap
Altair is one of the newer libraries on the block. Chart. cars ()Output: Ggplot. Fortunately, the pandas library has a divide() function that...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
alt.layer(points, lines, data = df)
will work. Altair 2.0.1 has totally new syntax for layered charts as vega-lite 2 do. Please check documentation on compound charts.The
add_selection
method was added in Altair version 2.1. If you update Altair, it should work.