Skip to content

inf line, dashing, thin bool - #1064

Merged
kushalkolar merged 6 commits into
ndwidgetfrom
inf-line-dashing
Aug 4, 2026
Merged

inf line, dashing, thin bool#1064
kushalkolar merged 6 commits into
ndwidgetfrom
inf-line-dashing

Conversation

@kushalkolar

Copy link
Copy Markdown
Member

closes #956 closes #994

Very simple API for inf lines and dashing:

# vertical lines at the zero-crossings, one color per line by passing a list of colors
zero_crossings = np.array([0, np.pi, 2 * np.pi, 3 * np.pi, 4 * np.pi])
figure[0, 0].add_inf_line(
    zero_crossings, axis="x", colors=["r", "g", "b", "c", "m"], thickness=2
)

# dashed horizontal lines at the sine bounds, provided as a 1D array of y-values
figure[0, 0].add_inf_line(
    np.array([-1.0, 1.0]),
    axis="y",
    colors="gray",
    thickness=2,
    dash_pattern="--",
)
image

@apasarkar

Can also provide pairs of points:

# an even number of points sampled around a circle; each consecutive pair of points defines an infinite line
t = np.linspace(0, 2 * np.pi, 64, endpoint=False)
xs = np.sin(t)
ys = np.cos(t)
positions = np.column_stack([xs, ys, np.zeros_like(xs)])
image

1D array of x values and a colormap is applied across the infinite lines in-order:

positions = np.arange(10)
figure[0, 0].add_inf_line(positions, axis="x", cmap="viridis", thickness=3)
image

cmap_transform, sets the color based on the sine value at the x-position

# color each line by an associated value using the colormap transform
values = np.sin(positions)
figure[0, 0].add_inf_line(
    positions, axis="x", cmap="plasma", cmap_transform=values, thickness=3
)
image

matplotlib style line dashing

patterns = ["-", "--", "-.", ":"]

for i, pattern in enumerate(patterns):
    ys = np.sin(xs) + i * 3
    data = np.column_stack([xs, ys])
    figure[0, 0].add_line(
        data, thickness=5, dash_pattern=pattern, name=pattern
    )
image

LLM disclosure: written by babysitting claude through it, read every line before accepting the changes.

@kushalkolar
kushalkolar requested a review from clewis7 as a code owner July 23, 2026 08:05
@kushalkolar

Copy link
Copy Markdown
Member Author

@clewis7 gtg!

@clewis7

clewis7 commented Jul 27, 2026

Copy link
Copy Markdown
Member

Why would the API for this not be:

fig[0,0].add_line(data, type="infinite")

as opposed to add_inf_line

If line and inf line are two different graphics, that could be determined under the hood and the proper one constructed??

@kushalkolar

Copy link
Copy Markdown
Member Author

Why would the API for this not be:

fig[0,0].add_line(data, type="infinite")

as opposed to add_inf_line

If line and inf line are two different graphics, that could be determined under the hood and the proper one constructed??

The inf line API is significantly different:

  • axis arg so data can be a 1D array. This is probably going to be the most common use of infinite lines. The way data works in infinite lines is just so different that I think it should be clear to the user. And as separate graphics, they have different adders since this is just autogenerated (the mixin)
  • start_is_infinite and end_is_infinite are unique properties to inf lines.

@clewis7

clewis7 commented Jul 28, 2026

Copy link
Copy Markdown
Member

@kushalkolar can you rebase with main???

@kushalkolar

Copy link
Copy Markdown
Member Author

@clewis7 gtg!

@kushalkolar
kushalkolar merged commit 4b2d0e8 into ndwidget Aug 4, 2026
@kushalkolar
kushalkolar deleted the inf-line-dashing branch August 4, 2026 16:08
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.

2 participants