File: pyramid.py

package info (click to toggle)
python-altair 5.0.1-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,952 kB
  • sloc: python: 25,649; sh: 14; makefile: 6
file content (20 lines) | stat: -rw-r--r-- 727 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
"""
Pyramid Pie Chart
-----------------
Altair reproduction of http://robslink.com/SAS/democd91/pyramid_pie.htm
"""
# category: case studies
import altair as alt
import pandas as pd

category = ['Sky', 'Shady side of a pyramid', 'Sunny side of a pyramid']
color = ["#416D9D", "#674028", "#DEAC58"]
df = pd.DataFrame({'category': category, 'value': [75, 10, 15]})

alt.Chart(df).mark_arc(outerRadius=80).encode(
    alt.Theta('value:Q', scale=alt.Scale(range=[2.356, 8.639])),
    alt.Color('category:N',
        scale=alt.Scale(domain=category, range=color),
        legend=alt.Legend(title=None, orient='none', legendX=160, legendY=50)),
    order='value:Q'
).properties(width=150, height=150).configure_view(strokeOpacity=0)