Skip to content

Commit 74ecb4d

Browse files
committed
add grid to azimuthal average
1 parent 8d51c3c commit 74ecb4d

File tree

1 file changed

+39
-8
lines changed

1 file changed

+39
-8
lines changed

hexrdgui/image_canvas.py

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
)
3636
from hexrdgui.utils.tth_distortion import apply_tth_distortion_if_needed
3737

38+
FONTSIZE_LABEL=15
39+
FONTSIZE_TICKS=15
3840

3941
class ImageCanvas(FigureCanvas):
4042

@@ -1050,7 +1052,7 @@ def finish_show_polar(self, iviewer):
10501052
'which': 'major',
10511053
'length': 10,
10521054
'labelfontfamily': 'serif',
1053-
'labelsize': 14
1055+
'labelsize': FONTSIZE_TICKS,
10541056
}
10551057
self.axis.tick_params(**kwargs)
10561058

@@ -1067,7 +1069,7 @@ def finish_show_polar(self, iviewer):
10671069
# overlays are drawn out-of-bounds
10681070
self.axis.autoscale(False)
10691071
self.axis.set_ylabel(
1070-
r'$\phi$ [deg]', fontsize=15, family='serif')
1072+
r'$\phi$ [deg]', fontsize=FONTSIZE_LABEL, family='serif')
10711073
self.axis.label_outer()
10721074
else:
10731075
rescale_image = False
@@ -1087,7 +1089,7 @@ def finish_show_polar(self, iviewer):
10871089
HexrdConfig().last_unscaled_azimuthal_integral_data = unscaled
10881090

10891091
self.azimuthal_integral_axis = axis
1090-
axis.set_ylabel(r'Azimuthal Average', fontsize=15, family='serif')
1092+
axis.set_ylabel(r'Azimuthal Average', fontsize=FONTSIZE_LABEL, family='serif')
10911093
self.update_azimuthal_plot_overlays()
10921094
self.update_wppf_plot()
10931095

@@ -1103,6 +1105,7 @@ def finish_show_polar(self, iviewer):
11031105
axis.xaxis.set_major_locator(AutoLocator())
11041106
axis.xaxis.set_minor_locator(AutoMinorLocator())
11051107

1108+
# change property of ticks
11061109
kwargs = {
11071110
'left': True,
11081111
'right': True,
@@ -1111,14 +1114,42 @@ def finish_show_polar(self, iviewer):
11111114
'which': 'major',
11121115
'length': 10,
11131116
'labelfontfamily': 'serif',
1114-
'labelsize': 14
1117+
'labelsize': FONTSIZE_TICKS,
11151118
}
11161119
axis.tick_params(**kwargs)
11171120

11181121
kwargs['which'] = 'minor'
11191122
kwargs['length'] = 2
11201123
axis.tick_params(**kwargs)
11211124

1125+
# add grid lines parallel to x-axis in azimuthal average
1126+
kwargs = {
1127+
'visible': True,
1128+
'which': 'major',
1129+
'axis': 'y',
1130+
'linewidth': 0.25,
1131+
'linestyle': '-',
1132+
'color': 'k',
1133+
'alpha': 0.75,
1134+
}
1135+
axis.grid(**kwargs)
1136+
1137+
kwargs = {
1138+
'visible': True,
1139+
'which': 'minor',
1140+
'axis': 'y',
1141+
'linewidth': 0.075,
1142+
'linestyle': '--',
1143+
'color': 'k',
1144+
'alpha': 0.9,
1145+
}
1146+
axis.grid(**kwargs)
1147+
1148+
# add grid lines parallel to y-axis
1149+
kwargs['which'] = 'both'
1150+
kwargs['axis'] = 'x'
1151+
axis.grid(**kwargs)
1152+
11221153
# Set our custom tick locators as well
11231154
# self.axis.xaxis.set_major_locator(PolarXAxisTickLocator(self))
11241155
# axis.xaxis.set_major_locator(PolarXAxisTickLocator(self))
@@ -1127,7 +1158,7 @@ def finish_show_polar(self, iviewer):
11271158
axis = self.azimuthal_integral_axis
11281159

11291160
# Update the xlabel in case it was modified (via tth distortion)
1130-
axis.set_xlabel(self.polar_xlabel, fontsize=15, family='serif')
1161+
axis.set_xlabel(self.polar_xlabel, fontsize=FONTSIZE_LABEL, family='serif')
11311162
else:
11321163
if len(self.axes_images) == 0:
11331164
self.axis = self.figure.add_subplot(111)
@@ -1139,13 +1170,13 @@ def finish_show_polar(self, iviewer):
11391170
'interpolation': 'none',
11401171
}
11411172
self.axes_images.append(self.axis.imshow(**kwargs))
1142-
self.axis.set_ylabel(r'$\phi$ [deg]', fontsize=15, family='serif')
1173+
self.axis.set_ylabel(r'$\phi$ [deg]', fontsize=FONTSIZE_LABEL, family='serif')
11431174
else:
11441175
rescale_image = False
11451176
self.axes_images[0].set_data(img)
11461177

11471178
# Update the xlabel in case it was modified (via tth distortion)
1148-
self.axis.set_xlabel(self.polar_xlabel, fontsize=15, family='serif')
1179+
self.axis.set_xlabel(self.polar_xlabel, fontsize=FONTSIZE_LABEL, family='serif')
11491180

11501181

11511182
if rescale_image:
@@ -1247,7 +1278,7 @@ def polar_x_axis_type(self):
12471278
def on_polar_x_axis_type_changed(self):
12481279
# Update the x-label
12491280
self.azimuthal_integral_axis.set_xlabel(self.polar_xlabel,
1250-
fontsize=15, family='serif')
1281+
fontsize=FONTSIZE_LABEL, family='serif')
12511282

12521283
# Still need to draw if the x-label was modified
12531284
self.draw_idle()

0 commit comments

Comments
 (0)