docs: Adds example Calculate Residuals#3625
Merged
dangotbanned merged 2 commits intomainfrom Oct 3, 2024
Merged
Conversation
Recreation of `vega-lite` example https://vega.github.io/vega-lite/examples/joinaggregate_residual_graph.html
Contributor
|
Thanks! This will become even prettier once #3505 is in. |
mattijn
approved these changes
Oct 2, 2024
Contributor
|
oh btw, you have to use underscores instead of spaces when using import altair as alt
from vega_datasets import data
imdb_rating = alt.datum["IMDB_Rating"]
chart = (
alt.Chart(data.movies.url)
.mark_point()
.transform_filter(imdb_rating != None)
.transform_filter(
alt.FieldRangePredicate("Release_Date", [None, 2019], timeUnit="year")
)
.transform_joinaggregate(AverageRating="mean(IMDB_Rating)")
.transform_calculate(RatingDelta=imdb_rating - alt.datum.AverageRating)
.encode(
x="Release_Date:T",
y=alt.Y("RatingDelta:Q").title("Rating Delta"),
color=alt.Color("RatingDelta:Q").title("Rating Delta").scale(domainMid=0),
)
)
chart |
Member
Author
🤦 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Recreation of
vega-liteexample https://vega.github.io/vega-lite/examples/joinaggregate_residual_graph.htmlI noticed the last example on Vega Theme Test didn't have an
altairequivalent.This PR will also bring us one step closer to #3519 (comment)
Really like how concise the methods syntax version ended up
Note
Wasn't able to use the url from
vega_datasets.data.movies.urlfor this, unsure why exactlyEdit
Fixed in docs: Use vega_datasets instead of url