Skip to content

Commit

Permalink
Raise exception if # applications > # markers
Browse files Browse the repository at this point in the history
The number of applications could exceed the number of markers because:
- We default to matplotlib's list of 16 "filled" markers; or
- A user-provided marker list is too small.

In both cases, an ApplicationStyle can be used to increase the number of
markers.

This change effects both Cascade and NavChart plots.

Signed-off-by: John Pennycook <john.pennycook@intel.com>
  • Loading branch information
Pennycook committed Apr 26, 2024
1 parent e365cc1 commit da4146d
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions p3/plot/backend/matplotlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,12 @@ def __init__(
markers = app_style.markers
if not isinstance(markers, (list, tuple)):
raise ValueError("Unsupported type provided for app_markers")
if len(applications) > len(markers):
raise RuntimeError(
f"The number of applications ({len(applications)}) is greater "
f"than the number of markers ({len(markers)}). "
+ "Please adjust the ApplicationStyle.",
)
app_markers = {app: color for app, color in zip(applications, markers)}

# Choose colors for each platform
Expand Down Expand Up @@ -566,6 +572,12 @@ def __init__(
markers = style.markers
if not isinstance(markers, (list, tuple)):
raise ValueError("Unsupported type provided for app_markers")
if len(applications) > len(markers):
raise RuntimeError(
f"The number of applications ({len(applications)}) is greater "
f"than the number of markers ({len(markers)}). "
+ "Please adjust the ApplicationStyle.",
)
app_markers = {
app: marker for app, marker in zip(applications, markers)
}
Expand Down

0 comments on commit da4146d

Please sign in to comment.