From 89b1254425aca1513e914f749f17e7c0bcce2276 Mon Sep 17 00:00:00 2001 From: Diana Date: Thu, 24 Oct 2024 10:25:26 +0200 Subject: [PATCH] Changed my plot function --- code/plot_functions.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/code/plot_functions.py b/code/plot_functions.py index 78cfcea..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"{points_categories}: {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')