Skip to content

Commit 91c1b9f

Browse files
committed
fixed interactive plot being returned was not displayed
1 parent 1b91ced commit 91c1b9f

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

src/axiomatic/pic_helpers.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import iklayout # type: ignore
22
import matplotlib.pyplot as plt # type: ignore
3-
from ipywidgets import interact # type: ignore
3+
from ipywidgets import interactive, IntSlider # type: ignore
44

55

66
def plot_circuit(component):
@@ -60,8 +60,23 @@ def plot_constraints(constraints: list[list[float]], constraints_labels: list[st
6060
plt.show()
6161

6262

63-
def interactive_spectrum_plot(
64-
spectrums: list[list[list[float]]],
63+
def plot_single_spectrum(spectrum: list[float],
64+
wavelengths: list[float],
65+
vlines: list[float] = None,
66+
hlines: list[float] = None):
67+
"""
68+
Plot a single spectrum with vertical and horizontal lines.
69+
"""
70+
plt.figure(figsize=(10, 5))
71+
plt.title("Losses vs. Iterations")
72+
plt.xlabel("Iterations")
73+
plt.ylabel("Losses")
74+
plt.plot(wavelengths, spectrum)
75+
plt.show()
76+
77+
78+
def plot_interactive_spectrums(
79+
spectrums: list[list[list[float]]] | list[list[float]],
6580
wavelengths: list[float],
6681
spectrum_labels: list[str] = None,
6782
slider_index: list[int] = None,
@@ -127,4 +142,5 @@ def plot_array(index=0):
127142
plt.grid(True)
128143
plt.show()
129144

130-
return interact(plot_array, index=slider_index)
145+
slider = IntSlider(value=0, min=0, max=len(spectrums[0]) - 1, step=1, description="Index")
146+
return interactive(plot_array, index=slider)

0 commit comments

Comments
 (0)