Exemplo n.º 1
0
    def _setup_axes_for_russian_regions_stat(self,
                                             ax: _figure.Axes,
                                             title: str = None,
                                             grid: bool = True,
                                             legend: bool = True,
                                             draw_key_dates: bool = True):
        ax.xaxis_date()

        if draw_key_dates:
            self.key_russian_dates(ax)

        if legend:
            ax.legend(loc='upper left')

        ax.set_ylim(bottom=0)

        if grid:
            ax.grid(axis='y', color='black', linestyle='dashed', alpha=0.4)

        if title:
            ax.set_title(title)
Exemplo n.º 2
0
def _draw_subplot(subplot: Subplot, ax: Axes, start: datetime.datetime,
                  end: datetime.datetime):

    data_series = [line.load(start, end) for line in subplot.lines]
    for line, data in zip(subplot.lines, data_series):
        _draw_series(data, ax, line)

    if subplot.ylim:
        if np.isfinite(subplot.ylim[0]):
            ax.set_ylim(bottom=subplot.ylim[0])
        if np.isfinite(subplot.ylim[1]):
            ax.set_ylim(top=subplot.ylim[1])

    ax.set_ylabel(subplot.ylabel, fontsize=subplot.plot.fontsize(1.2))

    # Show log book entries for the logsite of this subplot
    # Draw only logs if logsite is a site of the subplot's lines
    if subplot.logsite in [l.siteid for l in subplot.lines]:
        # Traverse logs and draw them
        for logtime, logtype, logtext in subplot.get_logs():
            x = np.datetime64(logtime)
            ax.axvline(x, linestyle='-', color='r', alpha=0.5, linewidth=3)
            ax.text(x,
                    ax.get_ylim()[0],
                    logtype,
                    ha='left',
                    va='bottom',
                    fontsize=subplot.plot.fontsize(0.9))

    ax.set_xlim(subplot.plot.start, subplot.plot.end)

    for xtl in ax.get_xticklabels():
        xtl.set_rotation(15)
    ax.yaxis.set_major_locator(MaxNLocator(prune='upper'))
    ax.tick_params(axis='both',
                   which='major',
                   labelsize=subplot.plot.fontsize(1.1))

    ax.grid()
    ax.legend(loc=0, prop=dict(size=subplot.plot.fontsize(1)))