Beispiel #1
0
    def test_that_relim_ignores_interactive_markers(self):
        """
        When calling .relim the content limits of the axes is calculated
        and a margin added. When the axes is resized the interactive
        markers re-calculate their limits to be the new axes limits,
        i.e. the original limits plus the margin. This mean repeatedly
        calling relim and autoscale will zoom out on the axes.

        This test makes sure this isn't happening and that the markers
        are ignored when calling .relim in this case.
        """
        fig, ax = plt.subplots(subplot_kw={'projection': 'mantid'})
        ax.plot([0, 1], [0, 1])
        y_min, y_max = ax.get_ylim()
        SingleMarker(
            fig.canvas,
            'g',
            0.5,
            y_min,
            y_max,
            marker_type='XSingle',
            axis=ax
        )
        ax.relim()
        ax.autoscale()
        np.testing.assert_almost_equal((y_min, y_max), ax.get_ylim())
Beispiel #2
0
 def _add_vertical_marker(self,
                          x_pos,
                          lower,
                          upper,
                          axis,
                          name=None,
                          line_style='dashed',
                          color=VALID_COLORS['green']):
     """
     Add a vertical marker to the plot and append it to the list of open markers
     :param x_pos: position to plot the marker to
     :param lower: y value to start the marker at
     :param upper: y value to stop the marker at
     :param name: label displayed beside the marker
     :param line_style: 'solid', 'dashed', etc.
     :param color: 'r', 'g', 'b' etc. or some hex code
     """
     if name is None:
         name = self._get_free_marker_name()
     marker = SingleMarker(self.canvas,
                           color,
                           x_pos,
                           lower,
                           upper,
                           name=name,
                           marker_type='XSingle',
                           line_style=line_style,
                           axis=axis)
     marker.add_name()
     marker.redraw()
     self.markers.append(marker)