Example #1
0
def plot_sticks(atoms: np.ndarray,
                ax: Axes,
                bt=(0.2, 2),
                nodup=True,
                threshold=0.1,
                **kwargs) -> None:
    """Plot bonds on given Axes.

    Parameters
    ----------
    atoms: array
        Array of atom positions (2D or 3D).
    ax: matplotlib.axes.Axes
        Axes to plot on.
    bs: tuple(int, int)
        Bond threshold, 
        e.g. (0.2, 2) means distance of atom between 0.2 and 2 (Å).
    nodup: bool
        No duplicate: if several bonds are overlayed, only plot one of them.
    threshold: float
        Threshold of two bonds to regard as duplicate.
    **kwargs: dict
        Matplotlib plot kwargs.
        Default style: {'color': 'tan', 'lw': 2, 'zorder': -1}.

    """
    style = {'color': 'tan', 'lw': 2, 'zorder': -1}
    style.update(kwargs)
    paired = bond_pair(atoms, bt)
    if nodup:
        paired = rm_dup_bond(paired)
    for pair in paired:
        ax.plot(pair[:, 0], pair[:, 1], **style)
Example #2
0
    def bar_with_sma_line(self,
                          ax: _figure.Axes,
                          values: _pd.Series,
                          sma_window: int = 7,
                          label: str = None,
                          bar_alpha: float = 0.3,
                          color: str = None):
        if label:
            ax.plot(values.rolling(window=sma_window).mean(),
                    label=label + "-SMA" + str(sma_window),
                    color=color)
        else:
            ax.plot(values.rolling(window=sma_window).mean(), color=color)

        ax.bar(values.index, values, alpha=bar_alpha, color=color)
Example #3
0
    def _draw_daily_stats(self, ax: _figure.Axes, df: _pd.DataFrame,
                          draw_key_dates: bool):
        index = df.index
        confirmed_daily = df.Confirmed_Change
        recovered_daily = df.Recovered_Change
        deaths_daily = df.Deaths_Change

        self.bar_with_sma_line(ax, confirmed_daily, label="Заболевшие")
        self.bar_with_sma_line(ax, recovered_daily, label="Выздоровевшие")

        ax.bar(index,
               deaths_daily,
               label='Смерти',
               alpha=0.3,
               bottom=recovered_daily)
        ax.plot(index,
                (recovered_daily + deaths_daily).rolling(window=7).mean(),
                label='Смерти-SMA7')

        self._setup_axes_for_russian_regions_stat(
            ax, "Статистика день ко дню", draw_key_dates=draw_key_dates)