示例#1
0
    def show_extrema(self, extrema_type):
        #Check for Valid Input
        if (extrema_type == str("MIN") or extrema_type == str("MAX")
                or extrema_type == str("ALL")):
            color_arr = []

            #Color List
            std_highlight = 'rgba(204,204,204,1)'
            min_highlight = 'rgba(222,45,38,0.8)'
            max_highlight = 'rgba(38,222,44,0.8)'

            #Apply Neutral Color Style
            for i in range(0, len(self.x_axis_values)):
                color_arr.append(std_highlight)

            #Find Min/Max and Assign Colors
            if (extrema_type == str("min")):
                color_arr[self.y_axis_values.index(min(
                    self.y_axis_values))] = min_highlight
            elif (extrema_type == str("max")):
                color_arr[self.y_axis_values.index(max(
                    self.y_axis_values))] = max_highlight
            elif (extrema_type == str("both")):
                color_arr[self.y_axis_values.index(max(
                    self.y_axis_values))] = max_highlight
                color_arr[self.y_axis_values.index(min(
                    self.y_axis_values))] = min_highlight

            #Set Marker with color_arr
            self.marker = dict(color=color_arr)
        else:
            #Return Error on Invalid Flag
            print("ERROR: Invalid higlight flag!")
            utils.halt()
示例#2
0
    def __init__(self,
                 plots,
                 output_format=utils.HTML,
                 output_path=None,
                 auto_render=False):
        #Apply Def Style to Plot
        self.apply_default_style()

        #Check Input Types
        if (type(plots) is list):
            self.multi_plots = []

            #Strip off styling from plots
            for plot in plots:
                self.multi_plots.append(plot.process()['data'][0])

            #Process Set Arguments
            if (not (output_path is None)):
                self.output_path = output_path
            if (auto_render):
                self.render(output_format=output_format,
                            auto_open=True,
                            output_path=output_path)
        else:
            #Return Error on Invalid Input
            print("ERROR: Invalid Input Type!")
            utils.halt()
示例#3
0
    def __init__(self,
                 plots,
                 group_type,
                 output_format=utils.HTML,
                 output_path=None,
                 auto_render=False):
        #Apply Def Style to Plot
        self.apply_default_style()

        #Check Input Types
        if (type(plots) is list and type(group_type) is str):
            self.multi_plots = []

            #group_type options ('stack', and 'group')
            if (group_type == "s"):
                self.bar_plot_type = "stack"
            elif (group_type == "g"):
                self.bar_plot_type = "group"
            else:
                #Return Error on Improper Flag
                print("ERROR: Improper Grouping Flag!")
                utils.halt()

            #Strip off styling from plots
            for plot in plots:
                self.multi_plots.append(plot.process()['data'][0])

            #Process Set Arguments
            if (not (output_path is None)):
                self.output_path = output_path
            if (auto_render):
                self.render(output_format=output_format, auto_open=True)
        else:
            #Return Error on Invalid Input
            print("ERROR: Invalid Input Type!")
            utils.halt()
示例#4
0
    def __init__(self,
                 input_1,
                 input_2,
                 plot_title=None,
                 zero_filter=False,
                 name=None,
                 output_format=utils.HTML,
                 output_path=None,
                 auto_render=False):
        #Add Style to Plot
        self.style_plot()
        if plot_title is not None:
            self.set_labels_manual(plot_label=plot_title)
        #Convert Inputs to Lists
        input_1 = (np.array(input_1).tolist())
        input_2 = (np.array(input_2).tolist())
        #Check Input Types
        if (type(input_1) is list) and (type(input_2) is list):
            #Set List Values
            self.x_axis_values = input_1
            self.y_axis_values = input_2

            #Return Error on Differing List Lengths
            if (not ((len(self.x_axis_values) == len(self.y_axis_values)))):
                print("ERROR: Differing list lengths!")
                utils.halt()
            else:
                #Process Filter Argument
                self.filter_data(zero_filter, self.x_axis_values,
                                 self.y_axis_values)

                # Process Set Arguments
                if (not (name is None)):
                    self.set_name(name)
                if (not (output_path is None)):
                    self.output_path = output_path
                if (auto_render):
                    self.render(output_format=output_format,
                                auto_open=True,
                                output_path=output_path)

        elif (type(input_1) is dict) and (type(input_2) is str):
            self.x_axis_values = []
            self.y_axis_values = []

            #Convert Dict to Lists
            for key in input_1:
                if (input_2 == "KEY_X"):
                    self.x_axis_values.append(key)
                    self.y_axis_values.append(input_1[key])
                elif (input_2 == "KEY_Y"):
                    self.x_axis_values.append(input_1[key])
                    self.y_axis_values.append(key)
                else:
                    #Return Error on Invalid Flag
                    print("ERROR: Invalid conversion flag!")
                    utils.halt()

            #Process Filter Argument
            self.filter_data(zero_filter, self.x_axis_values,
                             self.y_axis_values)

            #Process Set Arguments
            if (not (name is None)):
                self.set_name(name)
            if (not (output_path is None)):
                self.output_path = output_path
            if (auto_render):
                self.render(output_format=output_format,
                            auto_open=True,
                            output_path=output_path)
        else:
            #Return Error on Invalid Input
            print("ERROR: Invalid Input Type!")
            utils.halt()
    def _render_multi_plot(self, module_name, output_format = utils.HTML, output_path = None, auto_open = True):
        #Clean Module Name
        module_name = module_name.split(".")[1]

        #Render Appropriate Format
        if (output_format == utils.PNG):
            out_folder = utils.image_path
            if output_path is not  None:
                out_folder = output_path

            utils.make_container(out_folder)

            output_name = str(module_name) + "_" + utils.generate_id() + ".png"
            go.Figure(data = self.multi_plots).write_image(os.path.join(
                out_folder ,str(output_name)))

        elif (output_format == utils.PDF):

            out_folder = utils.pdf_path
            if output_path is not  None:
                out_folder = output_path

            utils.make_container(out_folder)

            output_name = str(module_name) + "_" + utils.generate_id() + ".pdf"
            go.Figure(data = self.multi_plots).write_image(os.path.join(
                out_folder ,str(output_name)))

        elif (output_format == utils.HTML):

            out_folder = utils.def_path
            if output_path is not None:
                out_folder = output_path

            utils.make_container(out_folder)

            #Render Plot
            if (utils.detect_notebook()):
                #Initialize Notebook Mode
                init_notebook_mode(connected = True)
                utils.clear_terminal()

                #Render Notebook Plot
                output_name = "notebook_" + str(module_name) + "_" +  \
                              utils.generate_id() + ".html"
                iplot(go.Figure(data = self.multi_plots, layout =
                self.generate_layout()), filename = os.path.join(
                    out_folder,str(output_name)))

            else:
                #Render Local Plot

                output_name = "loc_" + str(module_name) + "_" + utils.generate_id() + ".html"
                plot(go.Figure(data = self.multi_plots, layout = \
                    self.generate_layout()), filename = os.path.join(
                    out_folder,str(output_name)), auto_open = auto_open)
                return os.path.join(
                    out_folder,str(output_name))
        else:
            #Return Error on Invalid Output Format
            print("ERROR: Invalid Output Format!")
            utils.halt()
示例#6
0
    def __init__(self, input_1, view_mode = None, filter_type = None,
                 plot_title = None,zero_filter = False, name = None, \
                                                           output_format = utils.HTML, output_path = None, auto_render = False):
        #Add Style to Plot
        self.style_plot()

        if plot_title is not None:
            self.set_labels_manual(plot_label=plot_title)

        #Convert Input to List
        input = (np.array(input_1).tolist())
        input_1 = [
            input[0], input[1], input[1], input[2], input[3], input[3],
            input[4]
        ]
        input_1 = (np.array(input_1).tolist())

        #Check Input Type
        if (type(input_1) is list):
            #Set List Values
            self.data_in = input_1
            self.data_label = input

            #mode options ('m', 'msd')
            if (view_mode == "m"):
                self.mode = True
            elif (view_mode == 'msd'):
                self.mode = 'sd'
            elif (view_mode is None):
                self.mode = view_mode
            else:
                #Return Error on Invalid Flag
                print("ERROR: Invalid View Flag!")
                utils.halt()

            if (filter_type == "a"):
                self.filter = 'all'
            elif (filter_type == "w"):
                self.filter = False
            elif (filter_type == "s"):
                self.filter = "suspectedoutliers"
            elif (filter_type == "o"):
                self.filter = "outliers"
            elif (filter_type is None):
                self.filter = filter_type
            else:
                #Return Error on Invalid Flag
                print("ERROR: Invalid Filter Flag!")
                utils.halt()

            #Process Set Arguments
            if (not (name is None)):
                self.set_name(name)
            if (not (output_path is None)):
                self.output_path = output_path
            if (auto_render):
                self.render(output_format=output_format,
                            auto_open=True,
                            output_path=output_path)
        else:
            #Return Error on Invalid Input
            print("ERROR: Invalid Input Type!")
            utils.halt()
示例#7
0
    def __init__(self,
                 input_1,
                 input_2,
                 input_3,
                 plot_title=None,
                 output_format=utils.HTML,
                 output_path=None,
                 auto_render=False):

        #Apply Def Style to Plot
        self.style_plot()

        if plot_title is not None:
            self.set_labels_manual(plot_label=plot_title)

        #Convert Inputs to Lists
        input_1 = (np.array(input_1).tolist())
        input_2 = (np.array(input_2).tolist())
        input_3 = (np.array(input_3).tolist())

        #Check Input Types
        if (type(input_1) is list and type(input_2) is list
                and type(input_3) is list):
            #Determine Element Count
            z_axis_elems = 0

            for set in input_3:
                if (not (type(set) is list)):
                    #Return Error on Single Array Dimension
                    print("ERROR: Single Dimensional Array Detected!")
                    utils.halt()
                if (len(set) != len(input_1)):
                    #Swap Lists and Test Alignment
                    temp_input = input_1
                    input_1 = input_2
                    input_2 = temp_input

                    if (len(set) != len(input_1)):
                        #Return Error on Array Alignment
                        print("ERROR: Array dimensions do not align!")
                        utils.halt()
                    else:
                        print(
                            "CAUTION: Detected Array Misalignment. Swapped X and Y values!"
                        )

                z_axis_elems += len(set)

            #Error Check Array Lengths
            if ((len(input_1) * len(input_2)) != z_axis_elems):
                print("ERROR: Array dimensions do not align!")
                utils.halt()
            else:
                #Set List Values
                self.x_axis_values = input_1
                self.y_axis_values = input_2
                self.z_axis_values = input_3

            #Process Set Arguments
            if (not (output_path is None)):
                self.output_path = output_path
            if (auto_render):
                self.render(output_format=output_format,
                            auto_open=True,
                            output_path=output_path)
        else:
            #Return Error on Invalid Input
            print("ERROR: Invalid Input Type!")
            utils.halt()