Finish cleaning analyze_fft_ellipses.py

This commit is contained in:
2024-05-22 20:22:44 +02:00
parent 85bc972c54
commit a39a88c992

View File

@ -14,8 +14,7 @@ INTERESTING_VALUES_OF_AXES = {
Axis.ORDINATE: [0, 25, 40, 55, 70, 85, 100, 117, 135, 150, 167, 182],
}
halfHeight = height // 2
halfWidth = width // 2
halfHeight, halfWidth = np.array(secondImage.shape) // 2
PROFILES_OF_AXES = {
Axis.ABSCISSA: secondImage[halfHeight , halfWidth:],
Axis.ORDINATE: secondImage[halfHeight:, halfWidth ],
@ -24,7 +23,7 @@ PROFILES_OF_AXES = {
colorsOfAxes = {}
for axis in Axis:
plt.title('Axis Fourier transform profile\n\nLocal extremas have been listed manually from the Fourier transform visualization')
plt.title('Profiles of Fourier transform axes\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
@ -40,18 +39,18 @@ for axis in Axis:
def flattenDictValues(dict_):
return itertools.chain(*dict_.values())
# How to avoid hardcoding the default color being `black`?
# TODO: How to avoid hardcoding the default color being `black`?
MATPLOTLIB_DEFAULT_COLOR = 'black'
allInterestingValuesOfAxes = list(set(flattenDictValues(INTERESTING_VALUES_OF_AXES)))
ticks = list(plt.xticks()[0]) + allInterestingValuesOfAxes
plt.xticks(ticks)
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
# TODO: 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)