Ejemplo n.º 1
0
    def test_minor_tick_generator_with_interval(self):
        """If the MinorTickGenerator is not given an interval of 'auto',
        it should return the same results as a DefaultTickGenerator
        """
        self.default_tick_generator = DefaultTickGenerator()

        high = 1.0
        low = 0.0

        intervals = [0.05, 0.1, 0.2, 0.25, 0.5]

        for i in intervals:
            ticksMinor = self.tick_generator.get_ticks(
                data_low=0,
                data_high=1,
                bounds_low=low,
                bounds_high=high,
                interval=i,
            )
            ticksDefault = self.default_tick_generator.get_ticks(
                data_low=0,
                data_high=1,
                bounds_low=low,
                bounds_high=high,
                interval=i,
            )
            self.assertEqual(ticksMinor.tolist(), ticksDefault.tolist())
Ejemplo n.º 2
0
    def test_minor_tick_generator_without_interval(self):
        """A minor tick generator should return more ticks than
        the default tick generator.
        """
        self.default_tick_generator = DefaultTickGenerator()

        high = 1.0
        low = 0.0

        ticksMinor = self.tick_generator.get_ticks(
            data_low=0,
            data_high=1,
            bounds_low=low,
            bounds_high=high,
            interval='auto',
        )
        ticksDefault = self.default_tick_generator.get_ticks(
            data_low=0,
            data_high=1,
            bounds_low=low,
            bounds_high=high,
            interval='auto',
        )

        self.assertGreater(len(ticksMinor), len(ticksDefault))
Ejemplo n.º 3
0
class TestMinorTickGenerator(unittest.TestCase):

    def setUp(self):
        self.tick_generator = MinorTickGenerator()

    def test_minor_tick_generator_with_interval(self):
        """If the MinorTickGenerator is not given an interval of 'auto',
        it should return the same results as a DefaultTickGenerator
        """
        self.default_tick_generator = DefaultTickGenerator()
        
        high = 1.0
        low = 0.0
        
        intervals = [0.05, 0.1, 0.2, 0.25, 0.5]
        
        for i in intervals:
            ticksMinor = self.tick_generator.get_ticks(
                data_low=0,
                data_high=1,
                bounds_low=low,
                bounds_high=high,
                interval=i,
            )
            ticksDefault = self.default_tick_generator.get_ticks(
                data_low=0,
                data_high=1,
                bounds_low=low,
                bounds_high=high,
                interval=i,
            )
            self.assertEqual(ticksMinor.tolist(), ticksDefault.tolist())
    
    def test_minor_tick_generator_without_interval(self):
        """A minor tick generator should return more ticks than
        the default tick generator.
        """
        self.default_tick_generator = DefaultTickGenerator()
        
        high = 1.0
        low = 0.0
        
        ticksMinor = self.tick_generator.get_ticks(
            data_low=0,
            data_high=1,
            bounds_low=low,
            bounds_high=high,
            interval='auto',
        )
        ticksDefault = self.default_tick_generator.get_ticks(
            data_low=0,
            data_high=1,
            bounds_low=low,
            bounds_high=high,
            interval='auto',
        )
        
        self.assertGreater(len(ticksMinor), len(ticksDefault))
Ejemplo n.º 4
0
class TestMinorTickGenerator(unittest.TestCase):
    def setUp(self):
        self.tick_generator = MinorTickGenerator()

    def test_minor_tick_generator_with_interval(self):
        """If the MinorTickGenerator is not given an interval of 'auto',
        it should return the same results as a DefaultTickGenerator
        """
        self.default_tick_generator = DefaultTickGenerator()

        high = 1.0
        low = 0.0

        intervals = [0.05, 0.1, 0.2, 0.25, 0.5]

        for i in intervals:
            ticksMinor = self.tick_generator.get_ticks(
                data_low=0,
                data_high=1,
                bounds_low=low,
                bounds_high=high,
                interval=i,
            )
            ticksDefault = self.default_tick_generator.get_ticks(
                data_low=0,
                data_high=1,
                bounds_low=low,
                bounds_high=high,
                interval=i,
            )
            self.assertEqual(ticksMinor.tolist(), ticksDefault.tolist())

    def test_minor_tick_generator_without_interval(self):
        """A minor tick generator should return more ticks than
        the default tick generator.
        """
        self.default_tick_generator = DefaultTickGenerator()

        high = 1.0
        low = 0.0

        ticksMinor = self.tick_generator.get_ticks(
            data_low=0,
            data_high=1,
            bounds_low=low,
            bounds_high=high,
            interval='auto',
        )
        ticksDefault = self.default_tick_generator.get_ticks(
            data_low=0,
            data_high=1,
            bounds_low=low,
            bounds_high=high,
            interval='auto',
        )

        self.assertGreater(len(ticksMinor), len(ticksDefault))
Ejemplo n.º 5
0
 def test_minor_tick_generator_without_interval(self):
     """A minor tick generator should return more ticks than
     the default tick generator.
     """
     self.default_tick_generator = DefaultTickGenerator()
     
     high = 1.0
     low = 0.0
     
     ticksMinor = self.tick_generator.get_ticks(
         data_low=0,
         data_high=1,
         bounds_low=low,
         bounds_high=high,
         interval='auto',
     )
     ticksDefault = self.default_tick_generator.get_ticks(
         data_low=0,
         data_high=1,
         bounds_low=low,
         bounds_high=high,
         interval='auto',
     )
     
     self.assertGreater(len(ticksMinor), len(ticksDefault))
Ejemplo n.º 6
0
 def test_minor_tick_generator_with_interval(self):
     """If the MinorTickGenerator is not given an interval of 'auto',
     it should return the same results as a DefaultTickGenerator
     """
     self.default_tick_generator = DefaultTickGenerator()
     
     high = 1.0
     low = 0.0
     
     intervals = [0.05, 0.1, 0.2, 0.25, 0.5]
     
     for i in intervals:
         ticksMinor = self.tick_generator.get_ticks(
             data_low=0,
             data_high=1,
             bounds_low=low,
             bounds_high=high,
             interval=i,
         )
         ticksDefault = self.default_tick_generator.get_ticks(
             data_low=0,
             data_high=1,
             bounds_low=low,
             bounds_high=high,
             interval=i,
         )
         self.assertEqual(ticksMinor.tolist(), ticksDefault.tolist())
Ejemplo n.º 7
0
    def _set_x_axis_labels(self, plot):
        """ Set the x axis title, tick labels and styles.
        """
        x_labels = self.x_labels
        x_axis_style = self.plot_style.x_axis_style
        if x_labels:
            # if x_labels set, axis labels shouldn't be generated from the
            # numerical values but by the values stored in x_labels (for e.g.
            # when x_axis_col contains strings)
            label_rotation = x_axis_style.label_rotation
            label_positions = self.compute_label_positions(x_labels)
            if x_axis_style.show_all_labels:
                tick_generator = ShowAllTickGenerator(
                    positions=label_positions)
            else:
                tick_generator = DefaultTickGenerator()

            first_renderer = plot.components[0]
            bottom_axis = LabelAxis(first_renderer,
                                    orientation="bottom",
                                    labels=[str(x) for x in x_labels],
                                    positions=label_positions,
                                    label_rotation=label_rotation,
                                    tick_generator=tick_generator)
            # Store and replace in the underlay list...
            if plot.underlays:
                plot.underlays.pop(0)

            plot.underlays.insert(0, bottom_axis)
            plot.x_axis = bottom_axis

        plot.x_axis.title = self.x_axis_title
        font_size = x_axis_style.title_style.font_size
        font_name = x_axis_style.title_style.font_name
        plot.x_axis.title_font = '{} {}'.format(font_name, font_size)
Ejemplo n.º 8
0
class TestDefaultTickGenerator(unittest.TestCase):
    def setUp(self):
        self.tick_generator = DefaultTickGenerator()

    def test_default_tick_generator(self):

        high = 1.
        low = 0.
        interval = 0.1
        ticks = self.tick_generator.get_ticks(
            data_low=0,
            data_high=1,
            bounds_low=low,
            bounds_high=high,
            interval=interval, )
        expected_num_ticks = (high - low) / interval + 1
        self.assertEqual(len(ticks), expected_num_ticks)
Ejemplo n.º 9
0
class TestDefaultTickGenerator(unittest.TestCase):
    def setUp(self):
        self.tick_generator = DefaultTickGenerator()

    def test_default_tick_generator(self):

        high = 1.
        low = 0.
        interval = 0.1
        ticks = self.tick_generator.get_ticks(
            data_low=0,
            data_high=1,
            bounds_low=low,
            bounds_high=high,
            interval=interval,
        )
        expected_num_ticks = (high - low) / interval + 1
        self.assertEqual(len(ticks), expected_num_ticks)
Ejemplo n.º 10
0
    def _set_y_axis_labels(self, plot):
        """ Set the y axis title and style.
        """
        y_labels = self.y_labels
        y_axis_style = self.plot_style.y_axis_style
        if y_labels:
            # if y_labels set, axis labels shouldn't be generated from the
            # numerical values but by the values stored in y_labels (for e.g.
            # when y_axis column contains strings)
            label_rotation = y_axis_style.label_rotation
            label_positions = self.compute_label_positions(y_labels)
            if y_axis_style.show_all_labels:
                tick_generator = ShowAllTickGenerator(
                    positions=label_positions)
            else:
                tick_generator = DefaultTickGenerator()

            first_renderer = plot.components[0]
            left_axis = LabelAxis(first_renderer,
                                  orientation="left",
                                  labels=[str(x) for x in y_labels],
                                  positions=label_positions,
                                  label_rotation=label_rotation,
                                  tick_generator=tick_generator)
            # Store and replace in the underlay list...
            if plot.underlays:
                plot.underlays.pop(1)

            plot.underlays.insert(1, left_axis)
            plot.y_axis = left_axis

        if self.y_axis_title == "auto":
            styles = self.plot_style.renderer_styles
            plot.y_axis.title = ", ".join([
                desc["y"] for style, desc in zip(styles, self.renderer_desc)
                if style.orientation == STYLE_L_ORIENT
            ])
        else:
            plot.y_axis.title = self.y_axis_title

        font_size = self.plot_style.y_axis_style.title_style.font_size
        font_name = self.plot_style.y_axis_style.title_style.font_name
        plot.y_axis.title_font = '{} {}'.format(font_name, font_size)
Ejemplo n.º 11
0
 def setUp(self):
     self.tick_generator = DefaultTickGenerator()
Ejemplo n.º 12
0
 def setUp(self):
     self.tick_generator = DefaultTickGenerator()