File: stripplot.py

package info (click to toggle)
python-altair 4.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 9,972 kB
  • sloc: python: 22,391; makefile: 222; sh: 14
file content (40 lines) | stat: -rw-r--r-- 950 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
28
29
30
31
32
33
34
35
36
37
38
39
40
"""
Stripplot
---------
This example shows how to make a Stripplot.
"""
# category: scatter plots
import altair as alt
from vega_datasets import data

source = data.movies.url

stripplot =  alt.Chart(source, width=40).mark_circle(size=8).encode(
    x=alt.X(
        'jitter:Q',
        title=None,
        axis=alt.Axis(values=[0], ticks=True, grid=False, labels=False),
        scale=alt.Scale(),
    ),
    y=alt.Y('IMDB_Rating:Q'),
    color=alt.Color('Major_Genre:N', legend=None),
    column=alt.Column(
        'Major_Genre:N',
        header=alt.Header(
            labelAngle=-90,
            titleOrient='top',
            labelOrient='bottom',
            labelAlign='right',
            labelPadding=3,
        ),
    ),
).transform_calculate(
    # Generate Gaussian jitter with a Box-Muller transform
    jitter='sqrt(-2*log(random()))*cos(2*PI*random())'
).configure_facet(
    spacing=0
).configure_view(
    stroke=None
)

stripplot