File: wilkinson-dot-plot.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 (27 lines) | stat: -rw-r--r-- 570 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
21
22
23
24
25
26
27
"""
Wilkinson Dot Plot
------------------
An example of a `Wilkinson Dot Plot <https://en.wikipedia.org/wiki/Dot_plot_(statistics)>`_
"""
# category: advanced calculations

import altair as alt
import pandas as pd

source = pd.DataFrame(
    {"data":[1,1,1,1,1,1,1,1,1,1,
             2,2,2,
             3,3,
             4,4,4,4,4,4]
    }
)

alt.Chart(source).mark_circle(opacity=1).transform_window(
    id='rank()', 
    groupby=['data']
).encode(
    alt.X('data:O'), 
    alt.Y('id:O', 
          axis=None, 
          sort='descending')
).properties(height=100)