Skip to content

Commit

Permalink
docs: Update "Ranged Dot Plot" example (vega#3665)
Browse files Browse the repository at this point in the history
  • Loading branch information
dangotbanned authored Oct 30, 2024
1 parent 64c1e09 commit 211f7c5
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 48 deletions.
49 changes: 23 additions & 26 deletions tests/examples_arguments_syntax/ranged_dot_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,32 @@

source = data.countries.url

chart = alt.Chart(
data=source
).transform_filter(
filter={"field": 'country',
"oneOf": ["China", "India", "United States", "Indonesia", "Brazil"]}
).transform_filter(
filter={'field': 'year',
"oneOf": [1955, 2000]}
chart = (
alt.Chart(source)
.encode(x="life_expect:Q", y="country:N")
.transform_filter(
alt.FieldOneOfPredicate(
field="country",
oneOf=["China", "India", "United States", "Indonesia", "Brazil"],
)
)
.transform_filter(alt.FieldOneOfPredicate(field="year", oneOf=[1955, 2000]))
)

line = chart.mark_line(color='#db646f').encode(
x='life_expect:Q',
y='country:N',
detail='country:N'
)
line = chart.mark_line(color="#db646f").encode(detail="country:N")

# Add points for life expectancy in 1955 & 2000
points = chart.mark_point(
size=100,
opacity=1,
filled=True
).encode(
x='life_expect:Q',
y='country:N',
color=alt.Color('year:O',
scale=alt.Scale(
domain=[1955, 2000],
range=['#e6959c', '#911a24']
)
color = alt.Color(
"year:O", scale=alt.Scale(domain=[1955, 2000], range=["#e6959c", "#911a24"])
)
points = (
chart.mark_point(
size=100,
opacity=1,
filled=True,
)
).interactive()
.encode(color=color)
.interactive()
)

(line + points)
44 changes: 22 additions & 22 deletions tests/examples_methods_syntax/ranged_dot_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,30 @@

source = data.countries.url

chart = alt.Chart(
data=source
).transform_filter(
filter={"field": 'country',
"oneOf": ["China", "India", "United States", "Indonesia", "Brazil"]}
).transform_filter(
filter={'field': 'year',
"oneOf": [1955, 2000]}
chart = (
alt.Chart(source)
.encode(x="life_expect:Q", y="country:N")
.transform_filter(
alt.FieldOneOfPredicate(
field="country",
oneOf=["China", "India", "United States", "Indonesia", "Brazil"],
)
)
.transform_filter(alt.FieldOneOfPredicate(field="year", oneOf=[1955, 2000]))
)

line = chart.mark_line(color='#db646f').encode(
x='life_expect:Q',
y='country:N',
detail='country:N'
)
line = chart.mark_line(color="#db646f").encode(detail="country:N")

# Add points for life expectancy in 1955 & 2000
points = chart.mark_point(
size=100,
opacity=1,
filled=True
).encode(
x='life_expect:Q',
y='country:N',
color=alt.Color('year:O').scale(domain=[1955, 2000], range=['#e6959c', '#911a24'])
).interactive()
color = alt.Color("year:O").scale(domain=[1955, 2000], range=["#e6959c", "#911a24"])
points = (
chart.mark_point(
size=100,
opacity=1,
filled=True,
)
.encode(color=color)
.interactive()
)

(line + points)

0 comments on commit 211f7c5

Please sign in to comment.