Skip to content

Commit

Permalink
equal colors and step by 0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
mattijn committed Nov 10, 2023
1 parent 5998155 commit 7bc3654
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 26 deletions.
26 changes: 13 additions & 13 deletions tests/examples_arguments_syntax/interactive_aggregation.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,35 @@
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
from vega_datasets import data

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)
26 changes: 13 additions & 13 deletions tests/examples_methods_syntax/interactive_aggregation.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,35 @@
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
from vega_datasets import data

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)

0 comments on commit 7bc3654

Please sign in to comment.