From 7bc36544a9e567f64ab0ed5e78ab0fec9d3aff20 Mon Sep 17 00:00:00 2001 From: Mattijn van Hoek Date: Fri, 10 Nov 2023 16:47:25 +0100 Subject: [PATCH] equal colors and step by 0.1 --- .../interactive_aggregation.py | 26 +++++++++---------- .../interactive_aggregation.py | 26 +++++++++---------- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/tests/examples_arguments_syntax/interactive_aggregation.py b/tests/examples_arguments_syntax/interactive_aggregation.py index b98b789b8..ea8ae9905 100644 --- a/tests/examples_arguments_syntax/interactive_aggregation.py +++ b/tests/examples_arguments_syntax/interactive_aggregation.py @@ -5,7 +5,7 @@ threshold as rule where the datapoints on the left-side are aggregated and on the right-side are drawn as is. The ability to slide back and fourth may help you understand how the visualization -represents the aggregation. Example inspired by @dwootton. +represents the aggregation. Adapted from an example by @dwootton. """ # category: interactive charts import altair as alt @@ -13,27 +13,27 @@ source = data.movies() -slider = alt.binding_range(min=1, max=10, step=1) -threshold = alt.param(name='threshold', value=5, bind=slider) +slider = alt.binding_range(min=0, max=10, step=0.1) +threshold = alt.param(name="threshold", value=5, bind=slider) alt.layer( alt.Chart(source).mark_circle().encode( - x=alt.X('IMDB_Rating:Q', title='IMDB Rating'), - y=alt.Y('Rotten_Tomatoes_Rating:Q', title='Rotten Tomatoes Rating') + x=alt.X("IMDB_Rating:Q", title="IMDB Rating"), + y=alt.Y("Rotten_Tomatoes_Rating:Q", title="Rotten Tomatoes Rating") ).transform_filter( - alt.datum['IMDB_Rating'] > threshold + alt.datum["IMDB_Rating"] > threshold ), - alt.Chart(source).mark_circle(color='yellowgreen').encode( - x=alt.X('IMDB_Rating:Q', bin=alt.Bin(maxbins=10)), - y=alt.Y('Rotten_Tomatoes_Rating:Q', bin=alt.Bin(maxbins=10)), - size=alt.Size('count()', scale=alt.Scale(domain=[0,160])) + alt.Chart(source).mark_circle().encode( + x=alt.X("IMDB_Rating:Q", bin=alt.Bin(maxbins=10)), + y=alt.Y("Rotten_Tomatoes_Rating:Q", bin=alt.Bin(maxbins=10)), + size=alt.Size("count()", scale=alt.Scale(domain=[0,160])) ).transform_filter( - alt.datum['IMDB_Rating'] < threshold + alt.datum["IMDB_Rating"] < threshold ), - alt.Chart().mark_rule(color='gray').encode( + alt.Chart().mark_rule(color="gray").encode( strokeWidth=alt.StrokeWidth(value=3), - x=alt.X(datum=alt.expr(threshold.name), type='quantitative') + x=alt.X(datum=alt.expr(threshold.name), type="quantitative") ) ).add_params(threshold) \ No newline at end of file diff --git a/tests/examples_methods_syntax/interactive_aggregation.py b/tests/examples_methods_syntax/interactive_aggregation.py index 5096c76d6..7f69b9e23 100644 --- a/tests/examples_methods_syntax/interactive_aggregation.py +++ b/tests/examples_methods_syntax/interactive_aggregation.py @@ -5,7 +5,7 @@ threshold as rule where the datapoints on the left-side are aggregated and on the right-side are drawn as is. The ability to slide back and fourth may help you understand how the visualization -represents the aggregation. Example inspired by @dwootton. +represents the aggregation. Adapted from an example by @dwootton. """ # category: interactive charts import altair as alt @@ -13,27 +13,27 @@ source = data.movies() -slider = alt.binding_range(min=1, max=10, step=1) -threshold = alt.param(name='threshold', value=5, bind=slider) +slider = alt.binding_range(min=0, max=10, step=0.1) +threshold = alt.param(name="threshold", value=5, bind=slider) alt.layer( alt.Chart(source).mark_circle().encode( - x=alt.X('IMDB_Rating:Q').title('IMDB Rating'), - y=alt.Y('Rotten_Tomatoes_Rating:Q').title('Rotten Tomatoes Rating') + x=alt.X("IMDB_Rating:Q").title("IMDB Rating"), + y=alt.Y("Rotten_Tomatoes_Rating:Q").title("Rotten Tomatoes Rating") ).transform_filter( - alt.datum['IMDB_Rating'] > threshold + alt.datum["IMDB_Rating"] > threshold ), - alt.Chart(source).mark_circle(color='yellowgreen').encode( - x=alt.X('IMDB_Rating:Q').bin(maxbins=10), - y=alt.Y('Rotten_Tomatoes_Rating:Q').bin(maxbins=10), - size=alt.Size('count()').scale(domain=[0,160]) + alt.Chart(source).mark_circle().encode( + x=alt.X("IMDB_Rating:Q").bin(maxbins=10), + y=alt.Y("Rotten_Tomatoes_Rating:Q").bin(maxbins=10), + size=alt.Size("count()").scale(domain=[0,160]) ).transform_filter( - alt.datum['IMDB_Rating'] < threshold + alt.datum["IMDB_Rating"] < threshold ), - alt.Chart().mark_rule(color='gray').encode( + alt.Chart().mark_rule(color="gray").encode( strokeWidth=alt.StrokeWidth(value=3), - x=alt.X(datum=alt.expr(threshold.name), type='quantitative') + x=alt.X(datum=alt.expr(threshold.name), type="quantitative") ) ).add_params(threshold) \ No newline at end of file