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.

How to properly use `facet` and `resolve_scale` together?

See original GitHub issue

Hi I am trying to use resolve_scale() and facet() in the same chart but either don’t get the scale resolved or keep getting an error saying:

Javascript Error: Unrecognized scale name: "child_layer_0_y"

This usually means there's a typo in your chart specification. See the JavaScript console for the full traceback.

Here is the code:

from vega_datasets import data

cars = data.cars()

chart_base = alt.Chart(cars.sample(20, random_state=42))

chart_mpg = chart_base.encode(
    x='Name:N',
    y=alt.Y('Miles_per_Gallon:Q', scale=alt.Scale(type='linear'))
)

chart_weight = chart_base.transform_filter(
    alt.datum.Weight_in_lbs > 0  
).encode(
    x='Name:N',
    y=alt.Y('Weight_in_lbs:Q', scale=alt.Scale(base=10, type='log')),
    color=alt.value('red')
)

# this errors out
display((chart_mpg.mark_bar() + chart_weight.mark_line()).resolve_scale(y='independent').facet(column='Origin'))

# this works but the scale is not resolved
display((chart_mpg.mark_bar() + chart_weight.mark_line()).facet(column='Origin').resolve_scale(y='independent'))

And here is the working but wrong chart (the scale is not resolved, Miles_per_Gallon ends up on the same scale as Weight_in_lbs): visualization

  • May I know how to resolve this issue? Thanks~

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
gh-owestessoncommented, Mar 9, 2020

Agree that faceted multi-axis charts would be nice 👍

0reactions
blehmancommented, Oct 30, 2020

This thread on facets might be helpful. I used it to solve this related issue w/ facets.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Scale and Guide Resolution — Altair 4.2.0 documentation
A common technique for combining chart containing different measures is using a dual y axis. There are two strategies to achieve this result...
Read more >
17 Faceting - ggplot2: Elegant Graphics for Data Analysis
You can use multiple variables in the rows or columns, by “adding” them together, e.g. a + b ~ c + d ....
Read more >
Altair: Can't get independent 'y' scales with faceted heatmap
facet () method. This guy's answer gets me halfway there, but when I try to facet with rows and resolve the y scale...
Read more >
View topic - Starfighter Squadrons as Single Units - The Rancor Pit
My initial thought is to simply use the stat numbers from individual starfighters, but converted ... You'll also need to resolve scale modifier...
Read more >
Reviews - Taylor & Francis Online
tous use of the notion of a 'new' international division of labour, ... not consider how small dispersed entities are likely to resolve...
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