---------------------------------------------------------------------- This is the API documentation for the hubbub library. ---------------------------------------------------------------------- ## Profile README Introduce yourself, add badges, and scaffold the README build. who_am_i(name: 'str', likes: 'str', learn: 'str', work: 'str', collab: 'str', connect: 'bool' = True, delay: 'float' = 1.5, quiet: 'bool' = False) -> 'list[str]' Introduce yourself, one line at a time. Parameters ---------- name : str Your name. likes : str What you like. learn : str What you are learning. work : str What you are working on. collab : str What you would like to collaborate on. connect : bool Add the "Want to connect?" line. delay : float Seconds to pause between lines. Use `0` for none. quiet : bool Skip printing (useful when building README text). Returns ------- list of str The introduction lines. Examples -------- >>> lines = who_am_i("Martin", "#rstats.", "Python.", "packages.", ... "data science.", delay=0) # doctest: +ELLIPSIS 👋 Hi, my name is Martin. ... >>> len(lines) 6 who_am_i_gif(name: 'str', likes: 'str', learn: 'str', work: 'str', collab: 'str', connect: 'bool' = True, output: 'str | Path' = 'intro.gif', width: 'int' = 800, height: 'int' = 400, frame_duration: 'float' = 1.5, first_duration: 'float' = 1, last_duration: 'float' = 4, emoji_font: 'str | Path | None' = None) -> 'Path' Render the `who_am_i()` lines as a terminal style GIF. Each frame adds one line. Emoji come from the system color emoji font (Apple Color Emoji, Noto Color Emoji, or Segoe UI Emoji). Parameters ---------- name, likes, learn, work, collab : str Passed to the introduction lines (see `who_am_i()`). connect : bool Add the "Want to connect?" line. output : str or pathlib.Path Path for the `.gif` file. width, height : int GIF size in pixels. frame_duration : float Seconds to show each middle frame. first_duration : float Seconds to hold the first frame. last_duration : float Seconds to hold the last frame. emoji_font : str or pathlib.Path, optional A color emoji font file to use instead of the system one. Returns ------- pathlib.Path The output path. Warns ----- UserWarning If no emoji font is found; emoji are left out. gh_badges(username: 'str', badge: 'str | list[str]', theme: 'str' = 'default') -> 'str' Markdown image links for GitHub profile summary cards. Cards come from [github-profile-summary-cards](https://github-profile-summary-cards.vercel.app/demo.html). Parameters ---------- username : str GitHub username. badge : str or list of str One or more of `"details"`, `"commit_lang"`, `"ptime"`, `"repo_lang"`, or `"stats"`. theme : str `"default"`, `"dark"`, or `"light"`. Returns ------- str Markdown, one badge per line. Raises ------ ValueError If a badge or theme name is unknown. Examples -------- >>> print(gh_badges("mjfrigaard", ["details", "stats"], theme="dark")) ![](http://github-profile-summary-cards.vercel.app/api/cards/profile-details?username=mjfrigaard&theme=github_dark) ![](...stats?username=mjfrigaard&theme=github_dark) so_rep(username: 'str', user_id: 'str | int') -> 'str' HTML for a Stack Overflow reputation badge. Parameters ---------- username : str Stack Overflow username (the slug in your profile URL). user_id : str or int Stack Overflow user ID. Returns ------- str An `` tag wrapping the badge image. Examples -------- >>> print(so_rep("martin-frigaard", 4926446)) # doctest: +ELLIPSIS ... use_profile_readme(name: 'str' = 'Your Name', likes: 'str' = 'your interests', learn: 'str' = "what you're learning", work: 'str' = "what you're working on", collab: 'str' = "what you'd like to collaborate on", username: 'str' = 'your-github-username', path: 'str | Path' = '.', overwrite: 'bool' = False) -> 'Path' Write a starter `build_readme.py` for your profile repo. The script calls `who_am_i()` and `gh_badges()` and writes `README.md`. Optional blocks for `who_am_i_gif()` and `so_rep()` are included. Parameters ---------- name, likes, learn, work, collab : str Values filled into the `who_am_i()` call. username : str GitHub username filled into the `gh_badges()` call. path : str or pathlib.Path Directory to write into. overwrite : bool Replace an existing `build_readme.py`. Returns ------- pathlib.Path Path to the new file. Raises ------ FileExistsError If the file exists and `overwrite` is `False`. use_profile_readme_action(cron: 'str' = '0 6 * * 0', repo: 'str' = 'mjfrigaard/hubbub', path: 'str | Path' = '.', overwrite: 'bool' = False) -> 'Path' Write a GitHub Action that rebuilds the profile README on a schedule. Creates `.github/workflows/profile-readme.yaml`. The workflow installs hubbub with uv, runs `build_readme.py`, and commits `README.md` and any GIFs that changed. It also runs on manual dispatch. Parameters ---------- cron : str Cron schedule. The default, `"0 6 * * 0"`, is Sundays at 06:00 UTC. repo : str GitHub `owner/name` to install hubbub from. path : str or pathlib.Path Repo root to write into. overwrite : bool Replace an existing workflow file. Returns ------- pathlib.Path Path to the workflow file. Raises ------ FileExistsError If the file exists and `overwrite` is `False`. ## GitHub data Pull commits, stars, issues, and pull requests from the GitHub API. collect_git_commits(user: 'str', emails: 'str | list[str] | None' = None, since: 'str | date | datetime | None' = None, until: 'str | date | datetime | None' = None, include_forks: 'bool' = False, include: 'str | list[str]' = 'commits', tz: 'str | None' = None) -> 'pl.DataFrame | dict[str, pl.DataFrame]' Collect commits, stars, issues, and pull requests for a GitHub user. Calls the GitHub REST API. Set `GITHUB_PAT` or `GITHUB_TOKEN` first: unauthenticated calls are limited to 60 requests an hour, and the search endpoint (issues and PRs) returns at most 1000 results. Parameters ---------- user : str GitHub username. emails : str or list of str, optional Author emails to keep (case insensitive). Applies to commits only. since, until : str, datetime.date, or datetime.datetime, optional Bounds. API filters for commits; `created_at` bounds for issues and PRs. include_forks : bool Include forked repos (affects commits and stars). include : str or list of str Any of `"commits"`, `"stars"`, `"issues"`, `"prs"`. tz : str, optional Time zone for the local time columns. Defaults to the system zone. Returns ------- polars.DataFrame or dict of polars.DataFrame With the default `include="commits"`, one row per commit with columns `repo`, `sha`, `timestamp`, `author_name`, `author_email`, `message`, `local_ts`, `date`, `hour`, `weekday`, and `year`. Otherwise a dict keyed by type: - `stars`: the user's own repos with `stargazers_count`, `forks_count`, `watchers_count`, `language`, `description`, `created_at`, `updated_at`. - `issues`, `prs`: items authored by the user across GitHub, with `repo` (owner/name), `number`, `title`, `state`, `created_at`, `closed_at`, `url`. Examples -------- >>> commits = collect_git_commits( ... "mjfrigaard", emails="you@example.com" ... ) # doctest: +SKIP >>> stats = collect_git_commits( ... "mjfrigaard", include=["commits", "stars", "issues", "prs"] ... ) # doctest: +SKIP add_time_columns(df: 'pl.DataFrame', tz: 'str | None' = None) -> 'pl.DataFrame' Add local time columns to a commits DataFrame. Converts the UTC `timestamp` column to `tz` and adds `local_ts`, `date`, `hour`, `weekday` (a Monday to Sunday enum), and `year`. `collect_git_commits()` calls this for you; use it on commits loaded from a file. Parameters ---------- df : polars.DataFrame Must have a time zone aware `timestamp` column. tz : str, optional IANA time zone name, such as `"America/Phoenix"`. Defaults to the system zone. Returns ------- polars.DataFrame ## Commit charts Matplotlib charts of commit activity. calendar_heatmap_plot(commits: 'pl.DataFrame', repo: 'str | list[str] | None' = None, date_begin: 'str | date | None' = None, date_end: 'str | date | None' = None, title: 'str | None' = None, week_start: 'str' = 'Sunday', low: 'str' = '#ebedf0', high: 'str' = '#216e39') -> 'Figure' GitHub style calendar heatmap of daily commits, one row per year. Parameters ---------- commits : polars.DataFrame Commits from `collect_git_commits()`. repo : str or list of str, optional Repo name(s) to keep. `None` uses all repos. date_begin, date_end : str or datetime.date, optional Inclusive date bounds (`"YYYY-MM-DD"` strings work). title : str, optional Plot title. Defaults to the repo name(s) or `"All repos"`. week_start : str `"Sunday"` (GitHub's layout) or `"Monday"` (ISO weeks). low, high : str Colors for zero commits and the busiest day. Returns ------- matplotlib.figure.Figure cumulative_line_plot(commits: 'pl.DataFrame', repo: 'str | list[str] | None' = None, date_begin: 'str | date | None' = None, date_end: 'str | date | None' = None, top_n: 'int' = 10, show_other: 'bool' = True, title: 'str | None' = None) -> 'Figure' Cumulative commits over time, one step line per repo. Parameters ---------- commits : polars.DataFrame Commits from `collect_git_commits()`. repo : str or list of str, optional Repo name(s) to keep. `None` uses all repos. date_begin, date_end : str or datetime.date, optional Inclusive date bounds (`"YYYY-MM-DD"` strings work). top_n : int Number of most active repos drawn as their own lines. show_other : bool Roll the remaining repos into an `"Other"` line. title : str, optional Plot title. Defaults to the repo name(s) or `"All repos"`. Returns ------- matplotlib.figure.Figure punchcard_plot(commits: 'pl.DataFrame', repo: 'str | list[str] | None' = None, date_begin: 'str | date | None' = None, date_end: 'str | date | None' = None, title: 'str | None' = None, point_color: 'str' = '#1f6feb') -> 'Figure' Punchcard of commits by weekday and hour of day. Circle area is proportional to the number of commits. Parameters ---------- commits : polars.DataFrame Commits from `collect_git_commits()`. repo : str or list of str, optional Repo name(s) to keep. `None` uses all repos. date_begin, date_end : str or datetime.date, optional Inclusive date bounds (`"YYYY-MM-DD"` strings work). title : str, optional Plot title. Defaults to the repo name(s) or `"All repos"`. point_color : str Fill color for the circles. Returns ------- matplotlib.figure.Figure scatter_density_plot(commits: 'pl.DataFrame', repo: 'str | list[str] | None' = None, date_begin: 'str | date | None' = None, date_end: 'str | date | None' = None, x: 'str' = 'date', y: 'str' = 'time', plot_type: 'str' = 'matplotlib', top_n: 'int' = 15, title: 'str | None' = None, seed: 'int | None' = 1) -> 'Any' Scatter of commits across two of repo, time, date, and weekday. Categorical axes (repo, weekday) are jittered so stacked commits stay visible. Parameters ---------- commits : polars.DataFrame Commits from `collect_git_commits()`. repo : str or list of str, optional Repo name(s) to keep. `None` uses all repos. date_begin, date_end : str or datetime.date, optional Inclusive date bounds (`"YYYY-MM-DD"` strings work). x, y : str Each one of `"repo"`, `"time"`, `"date"`, `"weekday"`; they must differ. plot_type : str `"matplotlib"`, `"plotly"` (interactive; needs `hubbub[plotly]`), or `"density"` (matplotlib with marginal density curves). top_n : int When `"repo"` is an axis and `repo` is `None`, keep this many of the most active repos. title : str, optional Plot title. Defaults to the repo name(s) or `"All repos"`. seed : int, optional Seed for the jitter. Returns ------- matplotlib.figure.Figure or plotly.graph_objects.Figure ## Spiral charts One turn per year, from the center out. spiral_points_plot(commits: 'pl.DataFrame', repo: 'str | list[str] | None' = None, date_begin: 'str | date | None' = None, date_end: 'str | date | None' = None, title: 'str | None' = None, plot_type: 'str' = 'matplotlib') -> 'Any' Spiral of daily commits drawn as points sized by count. Parameters ---------- commits : polars.DataFrame Commits from `collect_git_commits()`. repo : str or list of str, optional Repo name(s) to keep. `None` uses all repos. date_begin, date_end : str or datetime.date, optional Inclusive date bounds (`"YYYY-MM-DD"` strings work). title : str, optional Legend title. Defaults to the repo name(s) or `"All repos"`. plot_type : str `"matplotlib"` for a static figure or `"plotly"` for an interactive one with hover labels (needs `hubbub[plotly]`). Returns ------- matplotlib.figure.Figure or plotly.graph_objects.Figure Notes ----- The spiral makes one turn per year, starting at the center, with January at the top and months running clockwise. spiral_heatmap_plot(commits: 'pl.DataFrame', repo: 'str | list[str] | None' = None, date_begin: 'str | date | None' = None, date_end: 'str | date | None' = None, title: 'str | None' = None, plot_type: 'str' = 'matplotlib') -> 'Any' Spiral of daily commits drawn as tiles colored by count. Parameters ---------- commits : polars.DataFrame Commits from `collect_git_commits()`. repo : str or list of str, optional Repo name(s) to keep. `None` uses all repos. date_begin, date_end : str or datetime.date, optional Inclusive date bounds (`"YYYY-MM-DD"` strings work). title : str, optional Colorbar title. Defaults to the repo name(s) or `"All repos"`. plot_type : str `"matplotlib"` for a static figure or `"plotly"` for an interactive one with hover labels (needs `hubbub[plotly]`). Returns ------- matplotlib.figure.Figure or plotly.graph_objects.Figure Notes ----- The spiral makes one turn per year, starting at the center, with January at the top and months running clockwise. spiral_horizon_plot(commits: 'pl.DataFrame', repo: 'str | list[str] | None' = None, date_begin: 'str | date | None' = None, date_end: 'str | date | None' = None, title: 'str | None' = None, n_bands: 'int' = 4, plot_type: 'str' = 'matplotlib') -> 'Any' Spiral horizon chart of daily commits. Counts are split into `n_bands` bands. Each bar's height shows the count within its band and its shade shows the band, so busy days read darker. Parameters ---------- commits : polars.DataFrame Commits from `collect_git_commits()`. repo : str or list of str, optional Repo name(s) to keep. `None` uses all repos. date_begin, date_end : str or datetime.date, optional Inclusive date bounds (`"YYYY-MM-DD"` strings work). title : str, optional Legend title. Defaults to the repo name(s) or `"All repos"`. n_bands : int Number of shade bands. plot_type : str `"matplotlib"` for a static figure or `"plotly"` for an interactive one with hover labels (needs `hubbub[plotly]`). Returns ------- matplotlib.figure.Figure or plotly.graph_objects.Figure Notes ----- The spiral makes one turn per year, starting at the center, with January at the top and months running clockwise. ## Animation Turn a folder of PNG frames into a GIF. make_gif(frame_dir: 'str | Path', output: 'str | Path', width: 'int', height: 'int', first_duration: 'float' = 1, frame_duration: 'float' = 0.4, last_duration: 'float' = 4) -> 'Path' Assemble a directory of PNG frames into a looping GIF. Frames are read in file name order, so name them `0001.png`, `0002.png`, and so on. The first and last frames get their own hold times. Parameters ---------- frame_dir : str or pathlib.Path Directory holding the `.png` frames. output : str or pathlib.Path Path for the `.gif` file. width, height : int GIF size in pixels. Frames are resized to fit. first_duration : float Seconds to hold the first frame. frame_duration : float Seconds to show each middle frame. last_duration : float Seconds to hold the last frame. Returns ------- pathlib.Path The output path. Raises ------ FileNotFoundError If `frame_dir` has no PNG files. ---------------------------------------------------------------------- This is the User Guide documentation for the package. ---------------------------------------------------------------------- ## Get started ### Get started `hubbub` makes some noise on your GitHub profile README. It introduces you as text or as an animated GIF, adds profile badges, pulls your activity from the GitHub API, and charts it. It is the Python counterpart to the R package [ghreadme](https://mjfrigaard.github.io/ghreadme/). ## Installation `hubbub` isn't on PyPI. Add the development version from GitHub to a uv project: ```bash uv add git+https://github.com/mjfrigaard/hubbub ``` or install it into the current environment: ```bash uv pip install git+https://github.com/mjfrigaard/hubbub ``` `hubbub` depends on `matplotlib`, `numpy`, `pillow`, and `polars`. Interactive scatter plots need the `plotly` extra (`hubbub[plotly]`). ## Your profile README GitHub shows the `README.md` from a repo named after your username (for example, `mjfrigaard/mjfrigaard`) at the top of your profile. In that repo, `use_profile_readme()` writes a `build_readme.py` script: ```python from hubbub import use_profile_readme use_profile_readme( name="Martin", likes="#rstats and data visualization.", learn="Shiny for Python app development and Linux administration.", work="Shiny app-package development tools.", collab="#rstats and #pystats packages for data science.", username="mjfrigaard", ) ``` Run it with `uv run --with hubbub python build_readme.py` (or `python build_readme.py` in an environment with `hubbub`) to write `README.md`. To rebuild it every week, add a GitHub Action: ```python from hubbub import use_profile_readme_action use_profile_readme_action(cron="0 6 * * 0") # Sundays at 06:00 UTC ``` ## Introductions `who_am_i()` prints your introduction one line at a time and returns the lines: ```{python} #| label: who-am-i from hubbub import who_am_i lines = who_am_i( name="Martin", likes="#rstats and data visualization.", learn="Shiny for Python app development and Linux administration.", work="Shiny app-package development tools.", collab="#rstats and #pystats packages for data science.", delay=0, ) ``` `who_am_i_gif()` takes the same arguments and writes the introduction as a terminal style GIF. The walkthrough shows the result. ## Badges `gh_badges()` returns Markdown for [GitHub profile summary cards](https://github-profile-summary-cards.vercel.app/demo.html), and `so_rep()` returns HTML for a Stack Overflow reputation badge: ```{python} #| label: badges from hubbub import gh_badges, so_rep print(gh_badges("mjfrigaard", badge=["details", "stats"], theme="dark")) ``` ```{python} #| label: so-rep print(so_rep(username="martin-frigaard", user_id=4926446)) ``` Next, the [walkthrough](01-walkthrough.qmd) pulls real data and charts it. ## Walkthrough ### Walkthrough: my profile README ```{python} #| label: setup #| include: false import tempfile from pathlib import Path import matplotlib.pyplot as plt import polars as pl import hubbub as hb out_dir = Path(tempfile.mkdtemp(prefix="hubbub-gifs-")) def show_gif(path): """Embed a GIF in the page so it survives rebuilds and the freeze cache.""" import base64 data = base64.b64encode(Path(path).read_bytes()).decode() print(f'') ``` On this page I'll build the charts and GIFs for my own profile README ([mjfrigaard/mjfrigaard](https://github.com/mjfrigaard/mjfrigaard)) with `hubbub`. We'll pull my GitHub activity, take a look at it, chart it a few ways, and then animate three of the charts. ## Collect the data `collect_git_commits()` calls the GitHub API, so set a token first (`export GITHUB_PAT=$(gh auth token)` works if you use the GitHub CLI). Asking for all four types returns a dict of DataFrames: ```python stats = hb.collect_git_commits( user="mjfrigaard", emails=["you@example.com", "you@work.example.com"], include=["commits", "stars", "issues", "prs"], tz="America/Phoenix", ) for name, df in stats.items(): df.write_parquet(f"data/{name}.parquet") ``` The `emails` filter keeps only commits I authored, and `tz` sets the time zone for the `local_ts`, `date`, `hour`, `weekday`, and `year` columns. Pulling every commit from every repo takes a few hundred API calls, so I saved the results to parquet files and read them back here: ```{python} #| label: read stats = { name: pl.read_parquet(f"data/{name}.parquet") for name in ["commits", "stars", "issues", "prs"] } commits = stats["commits"] {name: df.shape for name, df in stats.items()} ``` ## A first look Each row in `commits` is one commit: ```{python} #| label: glimpse commits.select("repo", "local_ts", "date", "hour", "weekday", "year").tail(5) ``` Which repos have the most commits? ```{python} #| label: top-repos ( commits.group_by("repo") .agg(commits=pl.len(), first=pl.col("date").min(), last=pl.col("date").max()) .sort("commits", descending=True) .head(8) ) ``` And which of my repos have the most stars? ```{python} #| label: stars stats["stars"].select("repo", "stargazers_count", "language").head(5) ``` The `issues` and `prs` tables cover everything I've opened across GitHub, not only in my own repos: ```{python} #| label: prs ( stats["prs"] .with_columns(owner=pl.col("repo").str.split("/").list.first()) .group_by("owner", "state") .agg(prs=pl.len()) .sort("prs", descending=True) ) ``` ## Charts Every chart function takes the commits DataFrame plus optional `repo`, `date_begin`, and `date_end` filters, and returns a matplotlib `Figure`. ### Calendar heatmap `calendar_heatmap_plot()` draws the familiar GitHub grid with one row per year: ```{python} #| label: calendar #| fig-width: 11 hb.calendar_heatmap_plot(commits, date_begin="2023-01-01"); ``` ### Cumulative commits `cumulative_line_plot()` keeps the `top_n` busiest repos as their own lines and rolls the rest into "Other": ```{python} #| label: cumulative hb.cumulative_line_plot(commits, date_begin="2023-01-01", top_n=8); ``` ### Punchcard `punchcard_plot()` shows when I commit, by weekday and hour (in Phoenix time): ```{python} #| label: punchcard hb.punchcard_plot(commits, date_begin="2023-01-01"); ``` ### Scatter with densities `scatter_density_plot()` plots any two of `"repo"`, `"time"`, `"date"`, and `"weekday"`. The `"density"` type adds marginal density curves: ```{python} #| label: scatter-density hb.scatter_density_plot( commits, date_begin="2025-01-01", x="date", y="time", plot_type="density" ); ``` Set `plot_type="plotly"` for an interactive version you can hover over: ```{python} #| label: scatter-plotly hb.scatter_density_plot( commits, date_begin="2025-01-01", x="weekday", y="time", plot_type="plotly" ) ``` ### Spirals The spiral charts make one turn per year, starting in the center, with January at the top. Each one shows the same daily counts a different way: ```{python} #| label: spiral-heatmap hb.spiral_heatmap_plot(commits, date_begin="2020-01-01"); ``` ```{python} #| label: spiral-points hb.spiral_points_plot(commits, date_begin="2020-01-01"); ``` ```{python} #| label: spiral-horizon hb.spiral_horizon_plot(commits, date_begin="2020-01-01"); ``` ### Interactive spiral Every spiral function also takes `plot_type="plotly"`. Hover over a bar to see the date and commit count, click a band in the legend to hide it, and drag to zoom: ```{python} #| label: spiral-plotly hb.spiral_horizon_plot(commits, date_begin="2020-01-01", plot_type="plotly") ``` GitHub strips JavaScript from READMEs, so my profile shows a static copy of this chart that links here: ```python fig = hb.spiral_horizon_plot(commits, date_begin="2020-01-01") fig.savefig("spiral.png", dpi=96, bbox_inches="tight", facecolor="white") ``` ## Animate the charts A GIF is a stack of frames. Each recipe below saves one chart per frame to a temporary folder, then `make_gif()` assembles them. Close each figure after saving it so they don't pile up in memory. ### Recipe 1: cumulative commits, sliding the end date ```{python} #| label: gif-cumulative #| output: asis from datetime import date ends = pl.date_range( date(2023, 2, 1), commits["date"].max(), interval="1mo", eager=True ) frames = Path(tempfile.mkdtemp()) for i, end in enumerate(ends, start=1): fig = hb.cumulative_line_plot( commits, date_begin="2023-01-01", date_end=end, top_n=8 ) fig.set_size_inches(10, 6) fig.savefig(frames / f"{i:04d}.png", dpi=96, facecolor="white") plt.close(fig) gif = hb.make_gif(frames, out_dir / "cumulative.gif", width=1000, height=600, first_duration=1, frame_duration=0.4, last_duration=4) show_gif(gif) ``` ### Recipe 2: calendar heatmap, year by year ```{python} #| label: gif-calendar #| output: asis years = sorted(commits.filter(pl.col("year") >= 2023)["year"].unique()) frames = Path(tempfile.mkdtemp()) for i, yr in enumerate(years, start=1): fig = hb.calendar_heatmap_plot( commits, date_begin=f"{years[0]}-01-01", date_end=f"{yr}-12-31", title=f"Through {yr}", ) fig.set_size_inches(11, 7) fig.savefig(frames / f"{i:04d}.png", dpi=96, facecolor="white") plt.close(fig) gif = hb.make_gif(frames, out_dir / "calendar.gif", width=1100, height=700, first_duration=1, frame_duration=1.2, last_duration=4) show_gif(gif) ``` ### Recipe 3: a punchcard for each top repo ```{python} #| label: gif-punchcard #| output: asis top_repos = ( commits.group_by("repo").agg(n=pl.len()) .sort("n", descending=True)["repo"].head(6).to_list() ) frames = Path(tempfile.mkdtemp()) for i, repo in enumerate(top_repos, start=1): fig = hb.punchcard_plot(commits, repo=repo) fig.set_size_inches(10, 5) fig.savefig(frames / f"{i:04d}.png", dpi=96, facecolor="white") plt.close(fig) gif = hb.make_gif(frames, out_dir / "punchcard.gif", width=1000, height=500, first_duration=1, frame_duration=1.5, last_duration=4) show_gif(gif) ``` To rank repos by stars instead, use `stats["stars"]["repo"].head(6)`. ### The introduction ```{python} #| label: gif-intro #| output: asis gif = hb.who_am_i_gif( name="Martin", likes="#rstats and data visualization.", learn="Shiny for Python app development and Linux administration.", work="Shiny app-package development tools.", collab="#rstats and #pystats packages for data science.", output=out_dir / "who_am_i.gif", ) show_gif(gif) ``` ## Put it in the README In the profile repo, save the GIFs next to `README.md` and point to them from `build_readme.py`: ```python sections = [ "# Hi there 👋", "![](who_am_i.gif)", "## GitHub activity", "![Cumulative commits](cumulative.gif)", "![Calendar heatmap](calendar.gif)", "![Punchcard](punchcard.gif)", hb.gh_badges("mjfrigaard", ["details", "stats", "repo_lang"], theme="dark"), ] Path("README.md").write_text("\n\n".join(sections) + "\n", encoding="utf-8") ```