Пример #1
0
    def format_3d_plot(self):
        """
        Used by 3d subclasses to format the plot
        """
        from cis.plotting.plot import plot_options
        import cis.plotting.overlay

        logx = self.plot_args.get("logx", False)
        logy = self.plot_args.get("logy", False)
        if logx or logy:
            self.set_log_scale(logx, logy)

        draw_grid = self.plot_args.get("grid")
        if draw_grid:
            self.matplotlib.grid(True, which="both")

        if self.is_map():
            self.drawcoastlines()

        self.set_axes_ticks(3)

        self.set_font_size()
        # If any of the options have not been specified, then use the defaults
        self.set_default_axis_label("X")
        self.set_default_axis_label("Y")

        if self.plot_args["xlabel"] is None:
            self.plot_args["xlabel"] = ""
        if self.plot_args["ylabel"] is None:
            self.plot_args["ylabel"] = ""
        if self.plot_args["title"] is None:
            self.plot_args["title"] = self.packed_data_items[0].long_name

        for key in list(plot_options.keys()):
            # Call the method associated with the option
            if key in list(self.plot_args.keys()):
                plot_options[key](self.plot_args[key])

        if not self.plot_args["nocolourbar"]:
            self.add_color_bar()

        if len(self.packed_data_items) > 1 and not isinstance(self, cis.plotting.overlay.Overlay):
            self.create_legend()
Пример #2
0
    def format_2d_plot(self):
        """
        Used by 2d subclasses to format the plot
        """
        import logging
        from cis.plotting.plot import plot_options

        logx = self.plot_args.get("logx", False)
        logy = self.plot_args.get("logy", False)
        if logx or logy:
            self.set_log_scale(logx, logy)
        else:
            try:
                self.matplotlib.gca().ticklabel_format(style='sci', scilimits=(-3, 3), axis='both')
            except AttributeError:
                logging.warning("Couldn't apply scientific notation to axes")

        draw_grid = self.plot_args.pop("grid", False)
        if draw_grid:
            self.matplotlib.grid(True, which="both")

        self.set_axes_ticks(2)

        self.set_font_size()

        # If any of the options have not been specified, then use the defaults
        self.set_default_axis_label("X")
        self.set_default_axis_label("Y")

        if self.plot_args["xlabel"] is None:
            self.plot_args["xlabel"] = ""
        if self.plot_args["ylabel"] is None:
            self.plot_args["ylabel"] = ""
        if self.plot_args["title"] is None:
            self.plot_args["title"] = ""

        for key in list(plot_options.keys()):
            # Call the method associated with the option
            if key in list(self.plot_args.keys()):
                plot_options[key](self.plot_args[key])

        if len(self.packed_data_items) > 1:
            self.create_legend()