From a396ac2e0784565327ddba1fb9477c5e0d754d01 Mon Sep 17 00:00:00 2001 From: Mattijn van Hoek Date: Wed, 13 Dec 2023 22:29:48 +0100 Subject: [PATCH] histogram with gradient color --- .../histogram_gradient_color.py | 23 +++++++++++++++++++ .../histogram_gradient_color.py | 17 ++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 tests/examples_arguments_syntax/histogram_gradient_color.py create mode 100644 tests/examples_methods_syntax/histogram_gradient_color.py diff --git a/tests/examples_arguments_syntax/histogram_gradient_color.py b/tests/examples_arguments_syntax/histogram_gradient_color.py new file mode 100644 index 000000000..404d58906 --- /dev/null +++ b/tests/examples_arguments_syntax/histogram_gradient_color.py @@ -0,0 +1,23 @@ +""" +Histogram with Gradient Color +----------------------------- +This example shows how to make a histogram with gradient color. +The low-high IMDB rating is represented with the color scheme `redyellowgreen`. +""" +# category: distributions +import altair as alt +from vega_datasets import data + +source = data.movies.url + +alt.Chart(source).mark_bar().encode( + alt.X("IMDB_Rating:Q", + bin=alt.Bin(maxbins=20), + scale=alt.Scale(domain=[1, 10]) + ), + alt.Y('count()'), + alt.Color("IMDB_Rating:Q", + bin=alt.Bin(maxbins=20), + scale=alt.Scale(scheme='redyellowgreen') + ) +) \ No newline at end of file diff --git a/tests/examples_methods_syntax/histogram_gradient_color.py b/tests/examples_methods_syntax/histogram_gradient_color.py new file mode 100644 index 000000000..92ccc9ce2 --- /dev/null +++ b/tests/examples_methods_syntax/histogram_gradient_color.py @@ -0,0 +1,17 @@ +""" +Histogram with Gradient Color +----------------------------- +This example shows how to make a histogram with gradient color. +The low-high IMDB rating is represented with the color scheme `redyellowgreen`. +""" +# category: distributions +import altair as alt +from vega_datasets import data + +source = data.movies.url + +alt.Chart(source).mark_bar().encode( + alt.X("IMDB_Rating:Q").bin(maxbins=20).scale(domain=[1, 10]), + alt.Y('count()'), + alt.Color("IMDB_Rating:Q").bin(maxbins=20).scale(scheme='redyellowgreen') +) \ No newline at end of file