Skip to content

Fix inconsistent axis labels in solimp documentation figures - #3548

Open
ManoharPaturi wants to merge 2 commits into
google-deepmind:mainfrom
ManoharPaturi:fix-solimp-figure-labels
Open

ManoharPaturi wants to merge 2 commits into
google-deepmind:mainfrom
ManoharPaturi:fix-solimp-figure-labels

Conversation

@ManoharPaturi

Copy link
Copy Markdown
Contributor

Body:

Fixes #3545

What does this PR do?

The solimp text in modeling.rst defines the impedance parameters as
$d_0$ and $d_{\text{width}}$ (since 83e7095), but the d(r) plot grid
(doc/images/modeling/impedance.png / impedance_dark.png) still labels
the vertical axis dmax / dmin — names that appear nowhere in the docs.

This regenerates both figures (light and dark) with the y-axis annotation
renamed to $d_0$ (bottom level, r = 0) and $d_{\text{width}}$ (top level,
r = ±width), matching the text. Everything else is reproduced faithfully:
same 3×3 panel grid (pow 1/2/6 × mid 0.1/0.5/0.9), same curve shapes
from the documented impedance interpolation, same dimensions (1580×1052),
same light/dark palettes, and the original labeling scheme (y labels only on
the top-left panel, x labels only on the bottom-left panel).

The curves use the impedance function as documented in the Modeling chapter:
d(r) = d₀ + (d_width − d₀) · S(|r|/width) with the power/midpoint spline
S(x) = 0.5·(x/y)^p for x ≤ y and 1 − 0.5·((1−x)/(1−y))^p otherwise.

How was it generated?

There is no figure-generation script in the repo, so the figures were
regenerated with the standalone matplotlib script below (happy to commit it
somewhere appropriate if you'd like to keep it):

generator script
import numpy as np
from PIL import Image
import matplotlib

matplotlib.use("Agg")
import matplotlib.pyplot as plt

WIDTH = 1.0


def d_of_r(r, d0, dwidth, midpoint, power):
    x = np.abs(r) / WIDTH
    s = np.where(
        x <= midpoint,
        0.5 * (x / midpoint) ** power,
        1.0 - 0.5 * ((1.0 - x) / (1.0 - midpoint)) ** power,
    )
    return d0 + (dwidth - d0) * s


def make_figure(theme):
    if theme == "light":
        bg, fg, grid_c, spine_c = "white", "black", "#efefef", "#929292"
    else:
        bg, fg, grid_c, spine_c = "black", "white", "#616161", "#dadada"

    plt.rcParams.update({
        "text.color": fg, "axes.labelcolor": fg,
        "xtick.color": fg, "ytick.color": fg, "font.size": 8.5,
    })

    fig, axes = plt.subplots(3, 3, figsize=(7.9, 5.26), dpi=200)
    r = np.linspace(-WIDTH, WIDTH, 1201)
    for row, mid in enumerate([0.1, 0.5, 0.9]):
        for col, power in enumerate([1, 2, 6]):
            ax = axes[row][col]
            ax.plot(r, d_of_r(r, 0.0, 1.0, mid, power), color=fg, linewidth=1.8)
            ax.set_title(f"pow {power}, mid {mid}", fontsize=8.5)
            ax.set_xlim(-1.25, 1.25)
            ax.set_ylim(-0.08, 1.08)
            ax.set_xticks([-1, 0, 1])
            ax.set_yticks([0, 1])
            ax.grid(True, color=grid_c, linewidth=0.7)
            for side in ("top", "right"):
                ax.spines[side].set_visible(False)
            for side in ("left", "bottom"):
                ax.spines[side].set_color(spine_c)
            ax.tick_params(length=3, labelsize=8)
            ax.set_xticklabels(
                ["-width", "0", "width"] if (row == 2 and col == 0) else ["", "", ""]
            )
            ax.set_yticklabels(
                [r"$d_0$", r"$d_\mathrm{width}$"] if (row == 0 and col == 0) else ["", ""]
            )
    fig.patch.set_facecolor(bg)
    fig.subplots_adjust(left=0.10, right=0.98, top=0.92, bottom=0.09, wspace=0.30, hspace=0.42)
    return fig


for theme, path in [
    ("light", "doc/images/modeling/impedance.png"),
    ("dark", "doc/images/modeling/impedance_dark.png"),
]:
    fig = make_figure(theme)
    fig.savefig(path, facecolor=fig.get_facecolor())
    plt.close(fig)
    if theme == "light":
        Image.open(path).convert("RGB").save(path)

@google-cla

google-cla Bot commented Sep 4, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Inconsistent axis labels in solimp documentation

1 participant