def figure_mouse_pick(self, event):
"""
Trigger for when the mouse is used to select an item in the figure.
:param event:
The matplotlib event.
"""
ycol = "abundance"
xcol = {
self.ax_excitation_twin: "expot",
self.ax_line_strength_twin: "reduced_equivalent_width"
}[event.inaxes]
xscale = np.ptp(event.inaxes.get_xlim())
yscale = np.ptp(event.inaxes.get_ylim())
try:
distance = np.sqrt(
((self._state_transitions[ycol] - event.ydata)/yscale)**2 \
+ ((self._state_transitions[xcol] - event.xdata)/xscale)**2)
except AttributeError:
# Stellar parameters have not been measured yet
return None
index = np.nanargmin(distance)
# Because the state transitions are linked to the parent source model of
# the table view, we will have to get the proxy index.
proxy_index = self.table_view.model().mapFromSource(
self.proxy_spectral_models.sourceModel().createIndex(index, 0)).row()
self.table_view.selectRow(proxy_index)
return None
评论列表
文章目录