Skip to content

Commit f165c2d

Browse files
authored
Fix tally indicator position on log-scale colorbars (#182)
1 parent b5113a3 commit f165c2d

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

openmc_plotter/plotgui.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -946,18 +946,18 @@ def updateTallyDataIndicatorValue(self, y_val):
946946
return
947947

948948
if self.tally_data_indicator is not None and self.tally_image is not None:
949-
# use norm to get axis value if log scale
950-
if cv.tallyDataLogScale:
951-
y_val = self.tally_image.norm(y_val)
952-
953949
# If indicator value hasn't changed, skip update
954950
if self._last_tally_indicator_value == y_val:
955951
return
956952
self._last_tally_indicator_value = y_val
957953

958954
data = self.tally_data_indicator.get_data()
955+
# Colorbar axes use data coordinates; normalization is only needed
956+
# when mapping the value through the colormap.
959957
self.tally_data_indicator.set_data([data[0], [y_val, y_val]])
960-
dl_color = invert_rgb(self.tally_image.get_cmap()(y_val), True)
958+
normalized_value = self.tally_image.norm(y_val)
959+
dl_color = invert_rgb(
960+
self.tally_image.get_cmap()(normalized_value), True)
961961
self.tally_data_indicator.set_c(dl_color)
962962

963963
if not self._blit_indicator(self.tally_data_indicator, self.tally_colorbar):
@@ -971,18 +971,18 @@ def updateDataIndicatorValue(self, y_val):
971971
return
972972

973973
if self.data_indicator and self.image is not None:
974-
# use norm to get axis value if log scale
975-
if cv.color_scale_log[cv.colorby]:
976-
y_val = self.image.norm(y_val)
977-
978974
# If indicator value hasn't changed, skip update
979975
if self._last_data_indicator_value == y_val:
980976
return
981977
self._last_data_indicator_value = y_val
982978

983979
data = self.data_indicator.get_data()
980+
# Colorbar axes use data coordinates; normalization is only needed
981+
# when mapping the value through the colormap.
984982
self.data_indicator.set_data([data[0], [y_val, y_val]])
985-
dl_color = invert_rgb(self.image.get_cmap()(y_val), True)
983+
normalized_value = self.image.norm(y_val)
984+
dl_color = invert_rgb(
985+
self.image.get_cmap()(normalized_value), True)
986986
self.data_indicator.set_c(dl_color)
987987

988988
if not self._blit_indicator(self.data_indicator, self.property_colorbar):

0 commit comments

Comments
 (0)