"""Rebuild the passport issuance charts from the published State and Census extracts.""" import hashlib import json from pathlib import Path import matplotlib matplotlib.use("Agg") import matplotlib.pyplot as plt import pandas as pd ROOT = Path(__file__).resolve().parent CHARTS = ROOT / "charts" STATE = "https://travel.state.gov/content/travel/en/about-us/reports-and-statistics.html" CENSUS = "https://www2.census.gov/programs-surveys/popest/datasets/2020-2025/state/totals/NST-EST2025-ALLDATA.csv" REGIONS = {1: "Northeast", 2: "Midwest", 3: "South", 4: "West"} REGION_ORDER = list(REGIONS.values()) PINK = "#8a4655" TEAL = "#245a56" GOLD = "#91651d" INK = "#30272a" PALE = "#faf6f1" CHART_PLAN = [] def load(): topics = { "national": pd.read_csv(ROOT / "national-issuance.csv"), "applications": pd.read_csv(ROOT / "applications.csv"), "stock": pd.read_csv(ROOT / "valid-documents.csv"), "states": pd.read_csv(ROOT / "state-issuance.csv"), "population": pd.read_csv(ROOT / "census-state-populations.csv", encoding="latin-1"), } assert set(topics["national"].fiscal_year) == set(range(1996, 2027)) assert set(topics["applications"].fiscal_year) == set(range(1986, 2027)) assert set(topics["stock"].fiscal_year) == set(range(1989, 2027)) assert len(topics["states"]) == topics["states"].state.nunique() == 56 assert topics["national"].passport_cards.notna().sum() == 19 return topics def start(title, *, rows=None): height = 4.55 if rows is None else max(4.25, min(6.4, 2.0 + .38 * rows)) figure, axes = plt.subplots(figsize=(10.3, height), layout="constrained") figure.set_facecolor(PALE) axes.set_facecolor(PALE) axes.set_title(title, loc="left", fontsize=15, fontweight="bold", color=INK, pad=13) axes.tick_params(axis="both", length=0, pad=7, colors=INK) axes.grid(axis="y" if rows is None else "x", color="#38323e", alpha=.15) axes.set_axisbelow(True) for spine in axes.spines.values(): spine.set_visible(False) return figure, axes def finish(slug, figure, axes, data, title, question, population, period, unit, takeaway, census=False): source_label = "U.S. Department of State" if census: source_label += " and U.S. Census Bureau Vintage 2025 estimates" figure.text(.018, .016, f"Visa & Entry analysis of {source_label}", color=INK, fontsize=8.5, va="bottom") figure.get_layout_engine().set(rect=(.018, .065, .96, .90)) figure.savefig(CHARTS / (slug + ".png"), dpi=132, facecolor=PALE) plt.close(figure) file = slug + ".csv" data.to_csv(CHARTS / file, index=False) CHART_PLAN.append(dict( asset=f"charts/{slug}.png", data=f"charts/{file}", title=title, question=question, population=population, period=period, unit=unit, takeaway=takeaway, sources=[STATE, CENSUS] if census else [STATE], source=[STATE, CENSUS] if census else [STATE], )) def line_chart(slug, data, series, ylim, title, *, question, population, period, unit, takeaway): figure, axes = start(title) for column, color in series.items(): axes.plot(data["Fiscal year"], data[column], label=column, color=color, linewidth=2.5, marker="o" if len(data) < 16 else None, markersize=4) axes.set_ylim(*ylim) axes.set_ylabel(unit, color=INK) axes.set_xlabel("Fiscal year", color=INK) if len(series) > 1: axes.legend(frameon=False, loc="upper left") finish(slug, figure, axes, data, title, question, population, period, unit, takeaway) def bar_chart(slug, data, title, *, column, xlim, question, population, period, unit, takeaway, census=False): figure, axes = start(title, rows=len(data)) colors = [TEAL if value >= 0 else PINK for value in data[column]] axes.barh(data.iloc[:, 0], data[column], color=colors, height=.62) axes.invert_yaxis() axes.axvline(0, linewidth=.75, color=INK) axes.set_xlabel(unit, color=INK) axes.set_xlim(*xlim) finish(slug, figure, axes, data, title, question, population, period, unit, takeaway, census) def main(): CHARTS.mkdir(exist_ok=True) sources = load() national = sources["national"].merge(sources["applications"], validate="one_to_one").merge( sources["stock"], validate="one_to_one" ).sort_values("fiscal_year", ignore_index=True) national["book_residual"] = national.total - national.passport_cards national["card_share"] = national.passport_cards.div(national.total).mul(100) geography = sources["states"] census = sources["population"].copy() census["REGION"] = pd.to_numeric(census.REGION, errors="coerce") census = census[census.SUMLEV.eq(40) & census.REGION.between(1, 4)].assign(state=lambda t: t.NAME.str.upper()) state = geography.merge(census[["state", "NAME", "REGION", "POPESTIMATE2025"]], on="state", validate="one_to_one") assert len(state) == 51 state["region"] = state.REGION.map(REGIONS) state["gap_2025"] = state.fy2026 - state.fy2025 state["rate"] = state.fy2026.div(state.POPESTIMATE2025).mul(100) states_only = state[state.NAME.ne("District of Columbia")] year = national.set_index("fiscal_year") delta = year.loc[2026] - year.loc[2025] assert len(states_only) == 50 and (states_only.gap_2025 < 0).all() assert year.loc[2026, "card_share"] == year.card_share.max() long = national[["fiscal_year", "total"]].rename(columns={"fiscal_year": "Fiscal year"}) long["Passports issued"] = long.pop("total").div(1_000_000) line_chart("chart-01-national-issuance", long, {"Passports issued": TEAL}, (0, 30), "Fiscal 2026 passport issuance was second only to 2025", question="Was the latest decline a return to pre-pandemic issuance?", population="All U.S. passports in the State Department fiscal-year issuance series", period="FY1996–FY2026", unit="Millions of documents", takeaway="FY2026 issued 25.37 million, below the 27.35 million record in FY2025.") type_change = pd.DataFrame({"Document": ["Non-card passports", "Passport cards"], "Change": [delta.book_residual / 1000, delta.passport_cards / 1000]}) bar_chart("chart-02-change-by-document", type_change, "Non-card passports accounted for most of the annual drop", column="Change", xlim=(-1900, 0), question="Which kind of document drove the decline?", population="U.S. passports issued; non-card counts subtract the reported passport cards from total", period="FY2025 to FY2026", unit="Change in thousands of documents", takeaway="Non-card issuance declined by 1.80 million, compared with 175,333 fewer passport cards.") cards = national.loc[national.passport_cards.notna(), ["fiscal_year", "card_share"]].rename( columns={"fiscal_year": "Fiscal year", "card_share": "Card share"}) line_chart("chart-03-card-share", cards, {"Card share": GOLD}, (0, 20), "Cards made up their largest share even as card issuance fell", question="Can cards fall in number and rise as a share of documents?", population="Passport cards divided by all U.S. passports issued where reported", period="FY2008–FY2026", unit="Percent of documents issued", takeaway="The card share increased from 16.62% to 17.22%, the highest among the published years.") largest = states_only.nsmallest(8, "gap_2025")[["NAME", "gap_2025"]].rename(columns={"NAME": "State"}) largest["Change"] = largest.pop("gap_2025").div(1000) bar_chart("chart-04-biggest-state-losses", largest, "California recorded the largest drop by volume", column="Change", xlim=(-350, 0), question="Where were the largest state declines?", population="Eight states with the largest decline in the State Department geographic table", period="FY2025 to FY2026", unit="Change in thousands of documents", takeaway="California, New Jersey, New York and Texas had the four largest losses.") regional = state.groupby("region")[["fy2026", "fy2025"]].sum().reindex(REGION_ORDER) regional["Change"] = 100 * (regional.fy2026 - regional.fy2025) / regional.fy2025 bar_chart("chart-05-census-regions", regional.reset_index(names="Census region")[["Census region", "Change"]], "The Northeast had the largest regional percentage decline", column="Change", xlim=(-12.5, 0), question="Do Census regions show the same rate of decline?", population="Fifty states and D.C. grouped in four Census regions, excluding territories", period="FY2025 to FY2026", unit="Percent change in documents issued", takeaway="Regional declines ranged from 6.64% in the Midwest to 10.55% in the Northeast.", census=True) rate_states = ["New Jersey", "Hawaii", "Massachusetts", "California", "Florida", "Texas", "Arkansas", "Mississippi", "West Virginia"] rates = states_only.set_index("NAME").loc[rate_states, ["rate"]].reset_index().rename( columns={"NAME": "State", "rate": "Documents per 100 residents"}) bar_chart("chart-06-issuance-per-resident", rates, "A population denominator changes the state comparison", column="Documents per 100 residents", xlim=(0, 9.5), question="How does issuance look after scaling to state population?", population="Selected states; FY2026 reported documents divided by July 1, 2025 Census resident population", period="FY2026 issuance, July 2025 population", unit="Documents per 100 estimated residents", takeaway="New Jersey led states, while Mississippi and West Virginia each reported fewer than three.", census=True) short = national[national.fiscal_year.ge(2019)][["fiscal_year", "total", "applications"]].rename( columns={"fiscal_year": "Fiscal year", "total": "Documents issued", "applications": "Applications received"}) short[["Documents issued", "Applications received"]] /= 1_000_000 line_chart("chart-07-applications-and-issuance", short, {"Documents issued": TEAL, "Applications received": PINK}, (0, 30), "Applications and documents issued both fell in fiscal 2026", question="Did the annual number of applications move in the same direction as output?", population="National State Department series for application forms and issued documents", period="FY2019–FY2026", unit="Millions", takeaway="Document issuance fell 7.2% and applications fell 6.9%.") stock = sources["stock"].sort_values("fiscal_year").rename(columns={"fiscal_year": "Fiscal year"}) stock["Valid passports"] = stock.pop("valid_passports").div(1_000_000) line_chart("chart-08-valid-documents", stock, {"Valid passports": TEAL}, (0, 204), "The number of valid passports continued to rise", question="Did fewer new documents correspond with fewer valid documents?", population="State Department count of valid U.S. passports, including books and cards", period="FY1989–FY2026", unit="Millions of valid documents", takeaway="The valid document stock rose to 190.50 million, even as annual issuance fell.") comparisons = pd.DataFrame({ "Prior fiscal year": [f"FY{year}" for year in range(2025, 2020, -1)], "States above prior level": [int(states_only.fy2026.gt(states_only[f"fy{year}"]).sum()) for year in range(2025, 2020, -1)], }) bar_chart("chart-09-geographic-baselines", comparisons, "The baseline changes how widespread the decline looks", column="States above prior level", xlim=(0, 52), question="How many states were above earlier fiscal years?", population="Fifty states, excluding D.C. and U.S. territories", period="FY2026 compared with FY2021–FY2025", unit="Number of states issuing more documents in FY2026", takeaway="All 50 were below FY2025, but 39 remained above FY2024.") inventory_files = { "national-issuance.csv": (STATE, "U.S. Passports Issued by Fiscal Year (1996–2026)"), "valid-documents.csv": (STATE, "Valid Passports in Circulation by Fiscal Year (1989–2026)"), "applications.csv": (STATE, "U.S. Passport Applications Received by Fiscal Year (1986–2026)"), "state-issuance.csv": (STATE, "Passport Issuance by State or Territory by Fiscal Year (2021–2026)"), "census-state-populations.csv": (CENSUS, "Vintage 2025 official population estimates, July 1, 2025"), } inventory = [{ "file": name, "url": url, "series": series, "sha256": hashlib.sha256((ROOT / name).read_bytes()).hexdigest(), } for name, (url, series) in inventory_files.items()] (ROOT / "source-manifest.json").write_text(json.dumps({ "coverage": "State Department page last updated October 21, 2026, checked December 3, 2026", "inputs": inventory, "notes": ["The four State Department datasets are numerical transcriptions of the agency's published HTML tables.", "Census population is an official CSV, using records whose summary level is 40 and whose region is 1–4.", "D.C. is included in Southern regional totals and excluded from the 50-state charts."], }, indent=2, ensure_ascii=False) + "\n", encoding="utf-8") (ROOT / "CHART-PLAN.json").write_text(json.dumps(CHART_PLAN, indent=2, ensure_ascii=False) + "\n", encoding="utf-8") if __name__ == "__main__": main()