Skip to content

fix: all_models.ipynb fails with newer matplotlib — tuple label in plt.plot() #648

Description

@Alex-l-r

Bug

notebooks/all_models.ipynb cell 21 fails with newer matplotlib versions:

ValueError: label must be scalar or have the same length as the input data, but found 2 for 1 datasets.

Root cause

The S-parameter dict keys are tuples (e.g. ("o1", "o2")). When passed directly as label=key, newer matplotlib interprets the tuple as a sequence of labels and expects one per dataset:

for key in S:
    plt.plot(f / 1e9, abs(S[key]) ** 2, label=key)  # key is ("o1", "o2") — fails

Fix

Convert the tuple to a string:

for key in S:
    plt.plot(f / 1e9, abs(S[key]) ** 2, label=str(key))

Metadata

Metadata

Assignees

Labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions