Exemple #1
0
    def calculate_bin_edges(self):
        """
        Calculates the number of bins for a given axis.
        Uses 10 as the default
        :param axis: The axis to calculate the number of bins for
        :return: The number of bins for the given axis
        """
        from cis.utils import calculate_histogram_bin_edges
        from numpy import array
        min_val = min(unpacked_data_item["data"].min() for unpacked_data_item in self.unpacked_data_items)
        max_val = max(unpacked_data_item["data"].max() for unpacked_data_item in self.unpacked_data_items)
        data = array([min_val, max_val])
        bin_edges = calculate_histogram_bin_edges(data, "x", self.plot_args["xrange"], self.plot_args["xbinwidth"],
                                                  self.plot_args["logx"])

        self.plot_args["xrange"]["xmin"] = bin_edges.min()
        self.plot_args["xrange"]["xmax"] = bin_edges.max()

        return bin_edges
Exemple #2
0
    def calculate_bin_edges(self, axis):
        """
        Calculates the number of bins for a given axis.
        Uses 10 as the default
        :param axis: The axis to calculate the number of bins for
        :return: The number of bins for the given axis
        """
        from cis.utils import calculate_histogram_bin_edges
        if axis == "x":
            data = self.unpacked_data_items[0]["data"]
        elif axis == "y":
            data = self.unpacked_data_items[1]["data"]

        bin_edges = calculate_histogram_bin_edges(data, axis, self.plot_args[axis + "range"],
                                                  self.plot_args[axis + "binwidth"], self.plot_args["log" + axis])

        self.plot_args[axis + "range"][axis + "min"] = bin_edges.min()
        self.plot_args[axis + "range"][axis + "max"] = bin_edges.max()

        return bin_edges