diff --git a/datasets/raise/fft/analyze_fft_ellipses.py b/datasets/raise/fft/analyze_fft_ellipses.py index a83e444..00d6f52 100644 --- a/datasets/raise/fft/analyze_fft_ellipses.py +++ b/datasets/raise/fft/analyze_fft_ellipses.py @@ -9,11 +9,9 @@ class Axis(Enum): def __str__(self): return self.name.title() -# TODO: with right color -# TODO: precising somehow low or high INTERESTING_VALUES_OF_AXES = { Axis.ABSCISSA: [0, 30, 60, 84, 108, 132, 160, 179], - Axis.ORDINATE: [0, 25, 40, 55, 70, 85, 100, 117], + Axis.ORDINATE: [0, 25, 40, 55, 70, 85, 100, 117, 135, 150, 167, 182], } halfHeight = height // 2 @@ -26,7 +24,7 @@ PROFILES_OF_AXES = { colorsOfAxes = {} for axis in Axis: - plt.title('Axis Fourier transform profile') + plt.title('Axis Fourier transform profile\n\nLocal extremas have been listed manually from the Fourier transform visualization') plt.xlabel('Fourier transform axis') plt.ylabel('Fourier transform logarithmic intensity') height, width = secondImage.shape @@ -35,13 +33,25 @@ for axis in Axis: for axis in Axis: for interestingValueOfAxisIndex, interestingValueOfAxis in enumerate(INTERESTING_VALUES_OF_AXES[axis]): - plt.axvline(interestingValueOfAxis, color = colorsOfAxes[axis], alpha = 0.3, linestyle = ':' if interestingValueOfAxisIndex % 2 == 0 else '--', label = 'Test') + linestyle = ':' if interestingValueOfAxisIndex % 2 == 0 else '--' + label = f'{axis} local {"minimum" if interestingValueOfAxisIndex == 0 else "maximum"}' if interestingValueOfAxisIndex <= 1 else None + plt.axvline(interestingValueOfAxis, color = colorsOfAxes[axis], alpha = 0.3, linestyle = linestyle, label = label) def flattenDictValues(dict_): return itertools.chain(*dict_.values()) +# How to avoid hardcoding the default color being `black`? +MATPLOTLIB_DEFAULT_COLOR = 'black' + allInterestingValuesOfAxes = list(set(flattenDictValues(INTERESTING_VALUES_OF_AXES))) -plt.xticks(list(plt.xticks()[0]) + allInterestingValuesOfAxes) +ticks = list(plt.xticks()[0]) + allInterestingValuesOfAxes +for tickIndex, tick in enumerate(ticks): + for axis in Axis: + if tick in INTERESTING_VALUES_OF_AXES[axis]: + #plt.xticklabels()[tickIndex].set_color(colorsOfAxes[axis]) + pltTick = plt.xticks()[1][tickIndex] + pltTick.set_color(MATPLOTLIB_DEFAULT_COLOR if axis == list(Axis)[-1] and pltTick.get_color() != MATPLOTLIB_DEFAULT_COLOR else colorsOfAxes[axis]) +# Changing tick color would be nice too, see https://stackoverflow.com/questions/49997934/change-color-of-specific-ticks-at-plot-with-matplotlib#comment108290728_49998338 allInterestingValuesOfAxesMin = min(allInterestingValuesOfAxes) allInterestingValuesOfAxesMax = max(allInterestingValuesOfAxes)