How to properly use `facet` and `resolve_scale` together?
See original GitHub issueHi 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
):
- May I know how to resolve this issue? Thanks~
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (2 by maintainers)
Top 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 >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
Agree that faceted multi-axis charts would be nice 👍
This thread on facets might be helpful. I used it to solve this related issue w/ facets.