<jupyter_start><jupyter_text>PSR B1919+21 Plot in Altair*Data: <NAME>, <NAME>*Adapted from d3 version at https://observablehq.com/@mbostock/psr-b1919-21, and [Vega-Lite version by Jeff Heer](https://observablehq.com/@vega/psr-b1919-21-with-vega-lite).<jupyter_code>import numpy as np
import pandas as pd
import altair as alt
# alt.renderers.enable('notebook')

# Note: data is in a CSV with no header info. We first load it as a 2D array,
# and then create a one-column dataframe where each entry is a list.
# This leads to a compact data representation, from which we use Altair
# transforms to tidy the data within the chart specification.
url = 'https://gist.githubusercontent.com/borgar/31c1e476b8e92a11d7e9/raw/0fae97dab6830ecee185a63c1cee0008f6778ff6/pulsar.csv'
values = np.genfromtxt(url, delimiter=',')
df = pd.Series(values.tolist(), name='data').to_frame()

# These values tweak the spacing & overlap between lines.
step=6
overlap=12

alt.Chart(df).transform_window(
    series='row_number()'
).transform_flatten(
    ['data']
).transform_window(
    index='row_number()',
    groupby=['series']
).mark_line(
    fill='white',
    stroke='black',
    strokeWidth=1
).encode(
    x=alt.X('index:Q', axis=None),
    y=alt.Y('data:Q', scale=alt.Scale(range=[step, -overlap * (step + 1)]), axis=None),
    row=alt.Row('series:O', header=alt.Header(title=None, labelPadding=0, labelFontSize=0)),
    tooltip=None
).properties(
    width=370,
    height=step,
    bounds='flush',
    spacing=0,
    padding=0,
).configure_view(
    stroke=None,
    fill='white'
)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1439299123904881, 'fraction_numerical': 0.041927409261576974, 'mean_word_length': 4.8145454545454545, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 3, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '566883', 'license': 'MIT', 'n_tokens_mistral': 620, 'n_tokens_neox': 579, 'n_words': 134, 'path': 'notebooks/PulsarPlot.ipynb', 'repo_name': 'jakevdp/altair-examples', 'size': '1620'}