Beispiel #1
0
    def makeMultiGraph(self, date, gtype, wannasave, val):
        try:
            fig_size_x = int(self.unit_data['GRAPH SIZE']['Xsize'])
            fig_size_y = int(self.unit_data['GRAPH SIZE']['Ysize'])
        except:
            fig_size_x = FIGSIZEX
            fig_size_y = FIGSIZEY

        # data setting
        day_type, position_data, player_data, graph_setting = self.settingData(
            date, gtype)

        fig_length = len(graph_setting)
        fig, ax = plt.subplots(fig_length,
                               1,
                               figsize=(fig_size_x, fig_size_y * fig_length))
        # fig.set_size_inches(fig_size_x, 6*fig_length, forward=True)

        for gi, gt in enumerate(gtype):
            bar_type, bar_data = self.getBarData(position_data, player_data,
                                                 graph_setting[gi]['Bar'])
            line_type, line_data = self.getLineData(position_data, player_data,
                                                    graph_setting[gi]['Line'])

            # basic information
            if bar_type[0] == 'Position':
                xlabel = position_data.index
            else:
                xlabel = player_data.index

            # window setting
            ax_twinx = ax[gi].twinx()

            plotBar(ax[gi], day_type, bar_type, bar_data, xlabel, wannasave,
                    val, date, self.unit_data, line_data)
            # draw right graph
            plotLine(ax_twinx, day_type, line_type, line_data, xlabel,
                     wannasave, val, date, self.unit_data, bar_data)

        # graph label setting
        # plt.subplots_adjust(wspace=10.)
        fig.tight_layout()

        if wannasave:
            fig.tight_layout()
            title = "{}__{} graph".format(date, 'Total')
            save_path = os.path.join(self.base_path, graph_path,
                                     config.IMAGE_CONFIG['Day Graph'],
                                     config.IMAGE_DAY_CONFIG['Total'],
                                     title + '.png')
            plt.savefig(save_path, dpi=300)
            plt.close()
            return None
        else:
            fig.set_size_inches(fig_size_y, 4 * fig_length)
            fig.tight_layout()
            return fig
Beispiel #2
0
    def makeSingleGraph(self, matchCamp, matchDate, matchInfo, gtype,
                        wannasave, val):
        try:
            fig_size_x = int(self.unit_data['GRAPH SIZE']['Xsize'])
            fig_size_y = int(self.unit_data['GRAPH SIZE']['Ysize'])
        except:
            fig_size_x = FIGSIZEX
            fig_size_y = FIGSIZEY
        match_title = matchDate + '__' + matchInfo
        day_type, position_data, position_avg, position_sum, player_data, graph_setting = self.settingData(
            matchCamp, matchDate, matchInfo, gtype)
        bar_type, bar_data = self.getBarData(position_data, position_avg,
                                             position_sum, player_data,
                                             graph_setting[0]['Bar'])
        line_type, line_data = self.getLineData(position_data, position_avg,
                                                position_sum, player_data,
                                                graph_setting[0]['Line'])

        # basic information
        if bar_type[0] == 'Position':
            xlabel = position_data.index
        elif bar_type[0] == 'Position Average':
            xlabel = position_avg.index
        elif bar_type[0] == 'Position Sum':
            xlabel = position_sum.index
        else:
            xlabel = player_data.index

        # window setting
        fig, ax = plt.subplots(1, 1, figsize=(fig_size_x, fig_size_y))
        # fig.set_size_inches(fig_size_x, 6, forward=True)
        ax_twinx = ax.twinx()

        # draw left graph
        plotBar(ax, day_type, bar_type, bar_data, xlabel, wannasave, val,
                match_title, self.unit_data, line_data)
        # draw right graph
        plotLine(ax_twinx, day_type, line_type, line_data, xlabel, wannasave,
                 val, match_title, self.unit_data, bar_data)

        if wannasave:
            fig.tight_layout()
            title = "{}__{}_{} graph".format(matchDate, matchInfo, gtype[0])
            save_path = os.path.join(self.base_path, graph_path,
                                     config.IMAGE_CONFIG['Match Day Graph'],
                                     config.IMAGE_MATCHDAY_CONFIG[gtype[0]],
                                     title + '.png')
            plt.savefig(save_path, dpi=300)
            plt.close()
            return None
        else:
            fig.set_size_inches(fig_size_y, 4)
            fig.tight_layout()
            return fig
Beispiel #3
0
    def makeMultiGraph(self, name, fromDate, toDate, gtype, wannasave, val):
        if int(fromDate) > int(toDate):
            return None
        try:
            fig_size_x = int(self.unit_data['GRAPH SIZE']['Xsize'])
            fig_size_y = int(self.unit_data['GRAPH SIZE']['Ysize'])
        except:
            fig_size_x = FIGSIZEX
            fig_size_y = FIGSIZEY

        # data setting
        player_data, team_data, graph_setting = self.settingData(
            name, fromDate, toDate, gtype)

        fig_length = len(graph_setting)
        fig, ax = plt.subplots(fig_length,
                               1,
                               figsize=(fig_size_x, fig_size_y * fig_length))
        # fig.set_size_inches(fig_size_x, 6*fig_length, forward=True)

        for gi, gt in enumerate(gtype):
            bar_type, bar_data, xlabel = self.getBarData(
                player_data, team_data, graph_setting[gi]['Bar'])
            line_type, line_data = self.getLineData(player_data, team_data,
                                                    graph_setting[gi]['Line'])

            # window setting
            ax_twinx = ax[gi].twinx()
            day_type = None
            plotBar(ax[gi], day_type, bar_type, bar_data, xlabel, wannasave,
                    val, name, self.unit_data, line_data)
            # draw right graph
            plotLine(ax_twinx, day_type, line_type, line_data, xlabel,
                     wannasave, val, name, self.unit_data, bar_data)

        # graph label setting
        # plt.subplots_adjust(wspace=10.)
        fig.tight_layout()

        if wannasave:
            fig.tight_layout()
            title = "{}'s {} graph ({}~{})".format(name, 'Total', fromDate,
                                                   toDate)
            save_path = os.path.join(self.base_path, graph_path,
                                     config.IMAGE_CONFIG['Player Graph'],
                                     config.IMAGE_PLAYER_CONFIG['Total'],
                                     title + '.png')
            plt.savefig(save_path, dpi=300)
            plt.close()
            return None
        else:
            fig.set_size_inches(fig_size_y, 4 * fig_length)
            fig.tight_layout()
            return fig
Beispiel #4
0
    def makeSingleGraph(self, name, fromDate, toDate, gtype, wannasave, val):
        if int(fromDate) > int(toDate):
            return None
        try:
            fig_size_x = int(self.unit_data['GRAPH SIZE']['Xsize'])
            fig_size_y = int(self.unit_data['GRAPH SIZE']['Ysize'])
        except:
            fig_size_x = FIGSIZEX
            fig_size_y = FIGSIZEY

        player_data, team_data, graph_setting = self.settingData(
            name, fromDate, toDate, gtype)
        bar_type, bar_data, xlabel = self.getBarData(player_data, team_data,
                                                     graph_setting[0]['Bar'])
        line_type, line_data = self.getLineData(player_data, team_data,
                                                graph_setting[0]['Line'])

        # window setting
        fig, ax = plt.subplots(1, 1, figsize=(fig_size_x, fig_size_y))
        # fig.set_size_inches(fig_size_x, 6, forward=True)
        ax_twinx = ax.twinx()

        day_type = None
        # draw left graph
        plotBar(ax, day_type, bar_type, bar_data, xlabel, wannasave, val, name,
                self.unit_data, line_data)
        # draw right graph
        plotLine(ax_twinx, day_type, line_type, line_data, xlabel, wannasave,
                 val, name, self.unit_data, bar_data)

        if wannasave:
            fig.tight_layout()
            title = "{}'s {} graph ({}~{})".format(name, gtype[0], fromDate,
                                                   toDate)
            save_path = os.path.join(self.base_path, graph_path,
                                     config.IMAGE_CONFIG['Player Graph'],
                                     config.IMAGE_PLAYER_CONFIG[gtype[0]],
                                     title + '.png')
            plt.savefig(save_path, dpi=300)
            plt.close()
            return None
        else:
            fig.set_size_inches(fig_size_y, 4)
            fig.tight_layout()
            return fig