-
Notifications
You must be signed in to change notification settings - Fork 794
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs: Add example of cumulative line chart with facet #3440
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for picking this up @dsmedia! I made a few suggestions to improve the original example here. I also think this might be a better fit for the advanced calculation section in the gallery since as you noted there is already a cumulative chart in the line category and the most interesting thing here is probably the more intricate use of filters.
tests/examples_arguments_syntax/line_chart_with_cumsum_faceted.py
Outdated
Show resolved
Hide resolved
tests/examples_methods_syntax/line_chart_with_cumsum_faceted.py
Outdated
Show resolved
Hide resolved
tests/examples_arguments_syntax/line_chart_with_cumsum_faceted.py
Outdated
Show resolved
Hide resolved
tests/examples_arguments_syntax/line_chart_with_cumsum_faceted.py
Outdated
Show resolved
Hide resolved
tests/examples_arguments_syntax/line_chart_with_cumsum_faceted.py
Outdated
Show resolved
Hide resolved
tests/examples_arguments_syntax/line_chart_with_cumsum_faceted.py
Outdated
Show resolved
Hide resolved
tests/examples_arguments_syntax/line_chart_with_cumsum_faceted.py
Outdated
Show resolved
Hide resolved
tests/examples_arguments_syntax/line_chart_with_cumsum_faceted.py
Outdated
Show resolved
Hide resolved
tests/examples_arguments_syntax/line_chart_with_cumsum_faceted.py
Outdated
Show resolved
Hide resolved
Ignore if you had a specific intend with the current scales, but I noticed there is a slight misalignment, especially the x-axis of 'epidemic' and 'flood'. This could be resolved by changing .resolve_scale(y='independent') to: .resolve_axis(y='independent', x='independent') Where the result will look like this: But again, if the current approach was with a certain intend, then please ignore this comment. Also linking #695. Maybe someone sees this as an opportunity to improve this current syntax .transform_filter(
{'and': [
alt.FieldOneOfPredicate(field='Entity', oneOf=columns_sorted), # Filter data to show only disasters in columns_sorted
alt.FieldRangePredicate(field='Year', range=[1900, 2000]) # Filter data to show only 20th century
]}
) Since this: alt.FieldOneOfPredicate(field='Entity', oneOf=columns_sorted) & alt.FieldRangePredicate(field='Year', range=[1900, 2000]) Returns currently: TypeError: unsupported operand type(s) for &: 'FieldOneOfPredicate' and 'FieldRangePredicate' |
Thanks for the suggestion, @mattijn. I've submitted the change. |
Thanks looks good! |
Description
This PR replaces the "Cumulative Wikipedia Donations" example with a new chart, based on issue #2424. The original example was broken and went against the Contribution guideline that requires local datasets, and a new faceted cumulative sum chart was proposed in 2021. This PR incorporates the suggestion made by @jakevdp to improve x-axis labels. The example was developed and proposed by @harabat, but had not been 100% finalized. I made some very small tweaks to get it working in Altair v5 and to incorporate small recommendations in #2424.
Changes Made
Issue Reference
Resolves #2424