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.

`Only chart objects can be used in ConcatChart` error when `concat` subcharts

See original GitHub issue

As per https://github.com/altair-viz/altair/issues/1925#issuecomment-669238407 when I try to horizontally alt.concat(three_subcharts), Altair raises ValueError: Only chart objects can be used in ConcatChart. I find this error confusing, because each of the three subcharts do individually plot correctly.

Code:

    brush = alt.selection(type='interval', resolve='global')
    three_subcharts = []
    hyperparams = [('Learning Rate', "log"), ('L2 Penalty', "log"), ('Dropout', "linear")]

    for hyperparam, scaling in hyperparams:
        color = alt.condition(brush, alt.ColorValue('red'), alt.ColorValue('gray'))

        chart = alt.Chart(data).mark_circle().encode(
            alt.X(hyperparam, type='quantitative', scale=alt.Scale(type=scaling)),
            alt.Y("Score", type='quantitative'),
            row=alt.Row("Metric", type='nominal'),
            color=color,
            tooltip=['Learning Rate', 'L2 Penalty', 'Dropout']
        ).add_selection(
           brush
        )
        three_subcharts.append(chart)

    print(three_subcharts)  # prints: [alt.Chart(...), alt.Chart(...), alt.Chart(...)] (each plots correctly as well)
    alt.concat(three_subcharts)  # ValueError: Only chart objects can be used in ConcatChart.

Data is in long format:

Dropout Learning Rate L2 Penalty Metric Score

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
jakevdpcommented, Aug 5, 2020

alt.concat does not accept a single argument containing a sequence; it accepts multiple arguments each of which is a chart. Try this instead:

alt.concat(three_subcharts[0], three_subcharts[1], three_subcharts[2])

or, equivalently,

alt.concat(*three_subcharts)
0reactions
crypdickcommented, Feb 22, 2021

Thanks for the update @joelostblom!

Read more comments on GitHub >

github_iconTop Results From Across the Web

altair.ConcatChart — Altair 4.2.0 documentation
A chart with horizontally-concatenated facets Mapping(required=[concat]) ... only the specified width and height values for the sub-view will be used.
Read more >
altair.ConcatChart — Altair 4.1.0 documentation
A chart with horizontally-concatenated facets Mapping(required=[concat]) ... This object is completely ignored by Vega and Vega-Lite and can be used for ...
Read more >
altair line up concatenated charts into a grid - You.com
The columns argument can be similarly specified for concatenated charts in alt.concat() and repeated charts alt.Chart.repeat() . Open side panel.
Read more >
Denotational Translation Validation The Harvard ... - CORE
with all of these positive results, translation validators that can be applied real-world compilers have not been available.
Read more >
lstdrvrs.dtx - CTAN
It is just what I % remember of the past. % \begin{macrocode} \lst@definelanguage[R/2 4.3]{ABAP}[R/2 5.0]{ABAP}% {deletekeywords={function,importing ...
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