diff --git a/code/plot_functions.py b/code/plot_functions.py index 1f84e19..7bf001f 100644 --- a/code/plot_functions.py +++ b/code/plot_functions.py @@ -110,11 +110,14 @@ def plot_highlighted_integrals(frequency, power, points, color_mapping, points_c # Define color based on the category of the point color = next((c for cat, c in color_mapping.items() if point in points_categories[cat]), 'gray') + # Find the category of the point + point_category = next((cat for cat, pts in points_categories.items() if point in pts), "Unknown") + # Shade the region around the point where the integral was calculated ax.axvspan(point - delta, point + delta, color=color, alpha=0.3, label=f'{point:.2f} Hz') - # Print out point and color - print(f"Integral around {point:.2f} Hz: {integral:.5e}, Color: {color}") + # Print out point, category, and color + print(f"{point_category}: Integral: {integral:.5e}, Color: {color}") # Annotate the plot with the point and its color ax.text(point, max(power) * 0.9, f'{point:.2f}', color=color, fontsize=10, ha='center') @@ -124,8 +127,8 @@ def plot_highlighted_integrals(frequency, power, points, color_mapping, points_c right_boundary = frequency[np.where((frequency > point + delta) & (frequency <= point + 5 * delta))[0][-1]] # Add vertical dashed lines at the boundaries of the adjacent regions - ax.axvline(x=left_boundary, color="k", linestyle="--") - ax.axvline(x=right_boundary, color="k", linestyle="--") + #ax.axvline(x=left_boundary, color="k", linestyle="--") + #ax.axvline(x=right_boundary, color="k", linestyle="--") ax.set_xlim([0, 1200]) ax.set_xlabel('Frequency (Hz)') diff --git a/code/useful_functions.py b/code/useful_functions.py index 72a58f6..6c17064 100644 --- a/code/useful_functions.py +++ b/code/useful_functions.py @@ -536,9 +536,9 @@ def valid_integrals(integral, local_mean, point, threshold = 0.1): """ valid = integral > (local_mean * (1 + threshold)) if valid: - print(f"The point {point} is valid, as its integral exceeds the threshold.") + print(f"The point {point} is valid.") else: - print(f"The point {point} is not valid, as its integral does not exceed the threshold.") + print(f"The point {point} is not valid.") return valid '''TODO Sarah: AM-freq plot: