|
1 | 1 | import iklayout # type: ignore |
2 | 2 | import matplotlib.pyplot as plt # type: ignore |
3 | | -from ipywidgets import interact # type: ignore |
| 3 | +from ipywidgets import interactive, IntSlider # type: ignore |
4 | 4 |
|
5 | 5 |
|
6 | 6 | def plot_circuit(component): |
@@ -60,8 +60,23 @@ def plot_constraints(constraints: list[list[float]], constraints_labels: list[st |
60 | 60 | plt.show() |
61 | 61 |
|
62 | 62 |
|
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]], |
65 | 80 | wavelengths: list[float], |
66 | 81 | spectrum_labels: list[str] = None, |
67 | 82 | slider_index: list[int] = None, |
@@ -127,4 +142,5 @@ def plot_array(index=0): |
127 | 142 | plt.grid(True) |
128 | 143 | plt.show() |
129 | 144 |
|
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