From 83363d12b8a56dacb5eb969bda108fdf2ab81ff5 Mon Sep 17 00:00:00 2001 From: palewire Date: Mon, 7 Jan 2019 23:21:10 -0800 Subject: [PATCH 1/5] Added simple isotype grid example --- altair/examples/isotype_grid.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 altair/examples/isotype_grid.py diff --git a/altair/examples/isotype_grid.py b/altair/examples/isotype_grid.py new file mode 100644 index 000000000..85020f10e --- /dev/null +++ b/altair/examples/isotype_grid.py @@ -0,0 +1,20 @@ +""" +Isotype grid +------------ +This example is a grid of isotype figures. +""" +# category: other charts +import altair as alt +import pandas as pd + +data = pd.DataFrame([dict(id=i) for i in range(1, 101)]) + +alt.Chart(data).transform_calculate( + col="ceil (datum.id/10)" +).transform_calculate( + row="datum.id - datum.col*10" +).mark_point(filled=True, size=50).encode( + x=alt.X("col:O", axis=None), + y=alt.Y("row:O", axis=None), + shape=alt.ShapeValue("M1.7 -1.7h-0.8c0.3 -0.2 0.6 -0.5 0.6 -0.9c0 -0.6 -0.4 -1 -1 -1c-0.6 0 -1 0.4 -1 1c0 0.4 0.2 0.7 0.6 0.9h-0.8c-0.4 0 -0.7 0.3 -0.7 0.6v1.9c0 0.3 0.3 0.6 0.6 0.6h0.2c0 0 0 0.1 0 0.1v1.9c0 0.3 0.2 0.6 0.3 0.6h1.3c0.2 0 0.3 -0.3 0.3 -0.6v-1.8c0 0 0 -0.1 0 -0.1h0.2c0.3 0 0.6 -0.3 0.6 -0.6v-2c0.2 -0.3 -0.1 -0.6 -0.4 -0.6z") +).properties(width=400, height=400) From f0516d13b31306cff2a04826b7faef1e97c761f7 Mon Sep 17 00:00:00 2001 From: palewire Date: Mon, 7 Jan 2019 23:22:05 -0800 Subject: [PATCH 2/5] Cut border --- altair/examples/isotype_grid.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/altair/examples/isotype_grid.py b/altair/examples/isotype_grid.py index 85020f10e..ad7d0f7b5 100644 --- a/altair/examples/isotype_grid.py +++ b/altair/examples/isotype_grid.py @@ -17,4 +17,7 @@ x=alt.X("col:O", axis=None), y=alt.Y("row:O", axis=None), shape=alt.ShapeValue("M1.7 -1.7h-0.8c0.3 -0.2 0.6 -0.5 0.6 -0.9c0 -0.6 -0.4 -1 -1 -1c-0.6 0 -1 0.4 -1 1c0 0.4 0.2 0.7 0.6 0.9h-0.8c-0.4 0 -0.7 0.3 -0.7 0.6v1.9c0 0.3 0.3 0.6 0.6 0.6h0.2c0 0 0 0.1 0 0.1v1.9c0 0.3 0.2 0.6 0.3 0.6h1.3c0.2 0 0.3 -0.3 0.3 -0.6v-1.8c0 0 0 -0.1 0 -0.1h0.2c0.3 0 0.6 -0.3 0.6 -0.6v-2c0.2 -0.3 -0.1 -0.6 -0.4 -0.6z") -).properties(width=400, height=400) +).properties( + width=400, + height=400 +).configure_view(strokeWidth=0) From 70ac037faf97724cf3ba8ae55b71c06409fcd60e Mon Sep 17 00:00:00 2001 From: palewire Date: Mon, 7 Jan 2019 23:23:47 -0800 Subject: [PATCH 3/5] trim --- altair/examples/isotype_grid.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/altair/examples/isotype_grid.py b/altair/examples/isotype_grid.py index ad7d0f7b5..fb9398272 100644 --- a/altair/examples/isotype_grid.py +++ b/altair/examples/isotype_grid.py @@ -10,7 +10,7 @@ data = pd.DataFrame([dict(id=i) for i in range(1, 101)]) alt.Chart(data).transform_calculate( - col="ceil (datum.id/10)" + col="ceil(datum.id/10)" ).transform_calculate( row="datum.id - datum.col*10" ).mark_point(filled=True, size=50).encode( From 8d81f1c8052addefc6203b3387f5606620c1815c Mon Sep 17 00:00:00 2001 From: Ben Welsh Date: Mon, 7 Jan 2019 23:24:29 -0800 Subject: [PATCH 4/5] Update isotype_grid.py --- altair/examples/isotype_grid.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/altair/examples/isotype_grid.py b/altair/examples/isotype_grid.py index fb9398272..1b8b6d9bd 100644 --- a/altair/examples/isotype_grid.py +++ b/altair/examples/isotype_grid.py @@ -1,5 +1,5 @@ """ -Isotype grid +Isotype Grid ------------ This example is a grid of isotype figures. """ From f90973c13a0d17369d63d390984c803337a3efed Mon Sep 17 00:00:00 2001 From: Ben Welsh Date: Tue, 8 Jan 2019 12:51:28 -0800 Subject: [PATCH 5/5] Update isotype_grid.py --- altair/examples/isotype_grid.py | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/altair/examples/isotype_grid.py b/altair/examples/isotype_grid.py index 1b8b6d9bd..fd446e4bc 100644 --- a/altair/examples/isotype_grid.py +++ b/altair/examples/isotype_grid.py @@ -9,15 +9,30 @@ data = pd.DataFrame([dict(id=i) for i in range(1, 101)]) +person = ( + "M1.7 -1.7h-0.8c0.3 -0.2 0.6 -0.5 0.6 -0.9c0 -0.6 " + "-0.4 -1 -1 -1c-0.6 0 -1 0.4 -1 1c0 0.4 0.2 0.7 0.6 " + "0.9h-0.8c-0.4 0 -0.7 0.3 -0.7 0.6v1.9c0 0.3 0.3 0.6 " + "0.6 0.6h0.2c0 0 0 0.1 0 0.1v1.9c0 0.3 0.2 0.6 0.3 " + "0.6h1.3c0.2 0 0.3 -0.3 0.3 -0.6v-1.8c0 0 0 -0.1 0 " + "-0.1h0.2c0.3 0 0.6 -0.3 0.6 -0.6v-2c0.2 -0.3 -0.1 " + "-0.6 -0.4 -0.6z" +) + alt.Chart(data).transform_calculate( - col="ceil(datum.id/10)" + row="ceil(datum.id/10)" ).transform_calculate( - row="datum.id - datum.col*10" -).mark_point(filled=True, size=50).encode( + col="datum.id - datum.row*10" +).mark_point( + filled=True, + size=50 +).encode( x=alt.X("col:O", axis=None), y=alt.Y("row:O", axis=None), - shape=alt.ShapeValue("M1.7 -1.7h-0.8c0.3 -0.2 0.6 -0.5 0.6 -0.9c0 -0.6 -0.4 -1 -1 -1c-0.6 0 -1 0.4 -1 1c0 0.4 0.2 0.7 0.6 0.9h-0.8c-0.4 0 -0.7 0.3 -0.7 0.6v1.9c0 0.3 0.3 0.6 0.6 0.6h0.2c0 0 0 0.1 0 0.1v1.9c0 0.3 0.2 0.6 0.3 0.6h1.3c0.2 0 0.3 -0.3 0.3 -0.6v-1.8c0 0 0 -0.1 0 -0.1h0.2c0.3 0 0.6 -0.3 0.6 -0.6v-2c0.2 -0.3 -0.1 -0.6 -0.4 -0.6z") + shape=alt.ShapeValue(person) ).properties( width=400, height=400 -).configure_view(strokeWidth=0) +).configure_view( + strokeWidth=0 +)