Skip to content

Commit 4391e1a

Browse files
authored
Merge pull request #20 from Axiomatic-AI/plot-spectrum-hline-fix
fixed hline bug in plot spectrum
2 parents 68d2364 + c1936b9 commit 4391e1a

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/axiomatic/pic_helpers.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def plot_single_spectrum(
9797
) # Add vertical line
9898
for y_val in hlines:
9999
plt.axhline(
100-
x=y_val, color="red", linestyle="--", label=f"Transmission (y={y_val})"
100+
y=y_val, color="red", linestyle="--", label=f"Transmission (y={y_val})"
101101
) # Add vertical line
102102
return plt.gcf()
103103

@@ -141,6 +141,9 @@ def plot_interactive_spectra(
141141
# Calculate global y-limits across all arrays
142142
y_min = min(min(min(arr2) for arr2 in arr1) for arr1 in spectra)
143143
y_max = max(max(max(arr2) for arr2 in arr1) for arr1 in spectra)
144+
if hlines:
145+
y_min = min(hlines + [y_min])*0.95
146+
y_max = max(hlines + [y_max])*1.05
144147

145148
slider_index = slider_index or list(range(len(spectra[0])))
146149
spectrum_labels = spectrum_labels or [f"Spectrum {i}" for i in range(len(spectra))]
@@ -159,7 +162,7 @@ def plot_array(index=0):
159162
) # Add vertical line
160163
for y_val in hlines:
161164
plt.axhline(
162-
x=y_val, color="red", linestyle="--", label=f"Transmission (y={y_val})"
165+
y=y_val, color="red", linestyle="--", label=f"Transmission (y={y_val})"
163166
) # Add vertical line
164167
plt.title(f"Iteration: {index}")
165168
plt.xlabel("X")

0 commit comments

Comments
 (0)