Exemplo n.º 1
0
    def plot_three_vars(paths, vars, fig):
        #retrive data
        axis = []
        data = []

        #get data
        x = getDataFromVar(paths[0], vars[0])
        y1 = getDataFromVar(paths[1], vars[1])
        y2 = getDataFromVar(paths[2], vars[2])

        axis.append(fig.add_subplot(1, 1, 1))

        #first y-axis
        color = 'tab:red'
        axis[0].set_xlabel(name(vars[0]) + unit(paths[0], vars[0]))
        axis[0].set_ylabel(name(vars[1]) + unit(paths[1], vars[1]))
        axis[0].plot(x, y1, color=color)
        axis[0].tick_params(axis=vars[1], labelcolor=color)

        #second y-axis
        axis[1] = axis[0].twinx(
        )  # instantiate a second axes that shares the same x-axis
        color = 'tab:blue'
        axis[1].plot(x, y2, color=color)
        axis[1].set_ylabel(name(vars[2]) + unit(paths[2], vars[2]))
        axis[1].tick_params(axis=vars[2], labelcolor=color)
        plt.title(
            header_info_to_plot(path1) + "\nPlot " + name(vars[1]) + "and " +
            name(vars[2]) + " against " + name(vars[0]))
        data.append(pd.Series(y1, index=x))
        data.append(pd.Series(y2, index=x))
        return axis, data
Exemplo n.º 2
0
    def plot_var_time(path, var, fig):
        #retrive time data and if not possible just return
        axis = []
        data = []

        timePath = findCorrespondingTime(path)
        if timePath is "":
            return
        time_data = []
        time = combineYMDHMwithSec(timePath)
        for t in time:
            time_data.append(t)
        #retive y-axis data
        y = getDataFromVar(path, var)

        #Create plot
        axis.append(fig.add_subplot(1, 1, 1))
        axis[0].set_title(
            header_info_to_plot(path) + "\n " + "Plot " + name(var) +
            " versus Time ")
        if len(time_data) == len(y):
            #axis[0].xticks(rotation= 80)
            axis[0].plot(time_data, y)
            axis[0].set_xlabel('Time')
            axis[0].set_ylabel(name(var) + unit(var))
            #axis[0].set_xticklabels(axis[0].get_xticklabels(), rotation=80)
            data.append(pd.Series(y, index=time_data))
        else:
            raise ValueError('Time and data do not have same length')
        return axis, data
Exemplo n.º 3
0
    def plot_two_vars(paths, vars, fig):

        # retrive data to plot
        x = getDataFromVar(paths[0], vars[0])
        y = getDataFromVar(paths[1], vars[1])
        axis = []
        data = []
        #create figure
        axis.append(fig.add_subplot(1, 1, 1))
        axis[0].plot(x, y)
        axis[0].set_title(
            header_info_to_plot(paths[0]) + '\n' + 'Plot' + name(vars[0]) +
            'versus ' + name(vars[1]))
        #ax.plot(x,y)
        axis[0].set_xlabel(name(vars[0]) + unit(paths[0], vars[0]))
        axis[0].set_ylabel(name(vars[1]) + unit(paths[1], vars[1]))
        data.append(pd.Series(y, index=x))
        return axis, data
Exemplo n.º 4
0
    def plot_two_var_time(paths, vars, fig):

        # Define return arrays'
        axis = []
        data = []

        #try to retrive time data, if can not just return
        timePath = findCorrespondingTime(paths[0])
        time = combineYMDHMwithSec(timePath)
        time_data = []
        i = 0
        for t in time:
            time_data.append(t)
        # retriv y-axis data
        y1 = getDataFromVar(paths[0], vars[0])
        y2 = getDataFromVar(paths[1], vars[1])

        if len(time) == len(y1) and len(time) == len(y2):
            axis.append(fig.add_subplot(1, 1, 1))
            #ax1 = fig.add_subplot(1,1,1)
            color = 'tab:red'
            axis[0].set_xlabel('Time H:M:S')
            axis[0].set_ylabel(name(vars[0]) + unit(paths[0], vars[0]))
            axis[0].plot(time_data, y1, color=color)
            #plt.xticks( rotation= 80 )
            axis[0].tick_params(axis=vars[0], labelcolor=color)
            axis.append(axis[0].twinx(
            ))  # instantiate a second y-axis that shares the same x-axis
            color = 'tab:blue'
            axis[1].plot(time_data, y2, color=color)
            axis[1].set_ylabel(name(vars[1]) + unit(paths[1], vars[1]))
            axis[1].tick_params(axis=vars[1], labelcolor=color)
            plt.title(
                header_info_to_plot(paths[0]) + "\nPlot " + name(vars[0]) +
                "and " + name(vars[1]) + " over time ")
            data.append(pd.Series(y1, index=time_data))
            data.append(pd.Series(y2, index=time_data))
            return axis, data
        else:
            print("Dimensions do not agree")
Exemplo n.º 5
0
 def plot_one_var(paths, vars, fig):
     y = getDataFromVar(paths[0], vars[0])
     x = range(1, len(y) + 1)
     axis = []
     data = []
     axis.append(fig.add_subplot(1, 1, 1))
     axis[0].plot(x, y)
     axis[0].set_title(
         header_info_to_plot(paths[0]) + '\n' + 'Plot' + name(vars[0]))
     axis[0].set_xlabel('Index')
     axis[0].set_ylabel(name(vars[0]) + unit(paths[0], vars[0]))
     data.append(pd.Series(y, index=x))
     return axis, data
Exemplo n.º 6
0
 def get_axis_lable(self):
     return name(self.var) + unit(self.path, self.var)