<gh_stars>0
"""
The title page.

Also creates an inset Axes that plots the logo for the corner of a slide. This
file is based on `examples/misc/logos2.py` in the Matplotlib repository.
"""

import numpy as np
import matplotlib.pyplot as plt
import matplotlib.cm as cm
from matplotlib.patches import Rectangle, PathPatch
from matplotlib.textpath import TextPath
import matplotlib.transforms as mtrans


from mplslide import MPL_BLUE, LOGO_FONT, FONT, new_slide


def create_icon_axes(fig, ax_position, lw_bars, lw_grid, lw_border, rgrid):
    """
    Create a polar axes containing the Matplotlib radar plot.

    Parameters
    ----------
    fig : matplotlib.figure.Figure
        The figure to draw into.
    ax_position : (float, float, float, float)
        The position of the created Axes in figure coordinates as
        (x, y, width, height).
    lw_bars : float
        The linewidth of the bars.
    lw_grid : float
        The linewidth of the grid.
    lw_border : float
        The linewidth of the Axes border.
    rgrid : array-like
        Positions of the radial grid.

    Returns
    -------
    ax : matplotlib.axes.Axes
        The created Axes.
    """
    with plt.rc_context({'axes.edgecolor': MPL_BLUE,
                         'axes.linewidth': lw_border}):
        ax = fig.add_axes(ax_position, projection='polar')
        ax.set_axisbelow(True)

        N = 7
        arc = 2 * np.pi
        theta = np.arange(0.0, arc, arc / N)
        radii = np.array([2, 6, 8, 7, 4, 5, 8])
        width = np.pi / 4 * np.array([0.4, 0.4, 0.6, 0.8, 0.2, 0.5, 0.3])
        bars = ax.bar(theta, radii, width=width, bottom=0.0, align='edge',
                      edgecolor='0.3', lw=lw_bars)
        for r, bar in zip(radii, bars):
            color = *cm.jet(r / 10.)[:3], 0.6  # color from jet with alpha=0.6
            bar.set_facecolor(color)

        ax.tick_params(labelbottom=False, labeltop=False,
                       labelleft=False, labelright=False)

        ax.grid(lw=lw_grid, color='0.9')
        ax.set_rmax(9)
        ax.set_yticks(rgrid)

        # The actual visible background - extends a bit beyond the axis
        ax.add_patch(Rectangle((0, 0), arc, 9.58,
                               facecolor='white', zorder=0,
                               clip_on=False, in_layout=False))
        return ax


def create_text_axes(fig, height_px):
    """Create an axes in *fig* that contains 'matplotlib' as Text."""
    ax = fig.add_axes((0, 0.4, 1, 0.5))
    ax.set_aspect("equal")
    ax.set_axis_off()

    path = TextPath((0, 0), "matplotlib", size=height_px * 0.8, prop=LOGO_FONT)

    angle = 4.25  # degrees
    trans = mtrans.Affine2D().skew_deg(angle, 0)

    patch = PathPatch(path, transform=trans + ax.transData, color=MPL_BLUE,
                      lw=0)
    ax.add_patch(patch)
    ax.autoscale()


def slides():
    """
    Create the title slide.
    """
    fig = new_slide(plain=True)

    create_text_axes(fig, 110)
    ax_pos = (0.535, 0.52, 0.17, 0.28)
    create_icon_axes(fig, ax_pos, 1.4, 1, 2, [1, 3, 5, 7])

    fig.text(0.5, 0.3, 'SciPy 2021',
             fontproperties=FONT, color='C0', fontsize=72)
    fig.text(0.5, 0.2, '@matplotlib',
             fontproperties=FONT, color='C0', fontsize=72)

    return fig

"""
The title page.

Also creates an inset Axes that plots the logo for the corner of a slide. This
file is based on `examples/misc/logos2.py` in the Matplotlib repository.
"""

import numpy as np
import matplotlib.pyplot as plt
import matplotlib.cm as cm
from matplotlib.patches import Rectangle, PathPatch
from matplotlib.textpath import TextPath
import matplotlib.transforms as mtrans


from mplslide import MPL_BLUE, LOGO_FONT, FONT, new_slide


def create_icon_axes(fig, ax_position, lw_bars, lw_grid, lw_border, rgrid):
    """
    Create a polar axes containing the Matplotlib radar plot.

    Parameters
    ----------
    fig : matplotlib.figure.Figure
        The figure to draw into.
    ax_position : (float, float, float, float)
        The position of the created Axes in figure coordinates as
        (x, y, width, height).
    lw_bars : float
        The linewidth of the bars.
    lw_grid : float
        The linewidth of the grid.
    lw_border : float
        The linewidth of the Axes border.
    rgrid : array-like
        Positions of the radial grid.

    Returns
    -------
    ax : matplotlib.axes.Axes
        The created Axes.
    """
    with plt.rc_context({'axes.edgecolor': MPL_BLUE,
                         'axes.linewidth': lw_border}):
        ax = fig.add_axes(ax_position, projection='polar')
        ax.set_axisbelow(True)

        N = 7
        arc = 2 * np.pi
        theta = np.arange(0.0, arc, arc / N)
        radii = np.array([2, 6, 8, 7, 4, 5, 8])
        width = np.pi / 4 * np.array([0.4, 0.4, 0.6, 0.8, 0.2, 0.5, 0.3])
        bars = ax.bar(theta, radii, width=width, bottom=0.0, align='edge',
                      edgecolor='0.3', lw=lw_bars)
        for r, bar in zip(radii, bars):
            color = *cm.jet(r / 10.)[:3], 0.6  # color from jet with alpha=0.6
            bar.set_facecolor(color)

        ax.tick_params(labelbottom=False, labeltop=False,
                       labelleft=False, labelright=False)

        ax.grid(lw=lw_grid, color='0.9')
        ax.set_rmax(9)
        ax.set_yticks(rgrid)

        # The actual visible background - extends a bit beyond the axis
        ax.add_patch(Rectangle((0, 0), arc, 9.58,
                               facecolor='white', zorder=0,
                               clip_on=False, in_layout=False))
        return ax


def create_text_axes(fig, height_px):
    """Create an axes in *fig* that contains 'matplotlib' as Text."""
    ax = fig.add_axes((0, 0.4, 1, 0.5))
    ax.set_aspect("equal")
    ax.set_axis_off()

    path = TextPath((0, 0), "matplotlib", size=height_px * 0.8, prop=LOGO_FONT)

    angle = 4.25  # degrees
    trans = mtrans.Affine2D().skew_deg(angle, 0)

    patch = PathPatch(path, transform=trans + ax.transData, color=MPL_BLUE,
                      lw=0)
    ax.add_patch(patch)
    ax.autoscale()


def slides():
    """
    Create the title slide.
    """
    fig = new_slide(plain=True)

    create_text_axes(fig, 110)
    ax_pos = (0.535, 0.52, 0.17, 0.28)
    create_icon_axes(fig, ax_pos, 1.4, 1, 2, [1, 3, 5, 7])

    fig.text(0.5, 0.3, 'SciPy 2021',
             fontproperties=FONT, color='C0', fontsize=72)
    fig.text(0.5, 0.2, '@matplotlib',
             fontproperties=FONT, color='C0', fontsize=72)

    return fig
The title page.  Also creates an inset Axes that plots the logo for the corner of a slide. This file is based on `examples/misc/logos2.py` in the Matplotlib repository. Create a polar axes containing the Matplotlib radar plot.      Parameters     ----------     fig : matplotlib.figure.Figure         The figure to draw into.     ax_position : (float, float, float, float)         The position of the created Axes in figure coordinates as         (x, y, width, height).     lw_bars : float         The linewidth of the bars.     lw_grid : float         The linewidth of the grid.     lw_border : float         The linewidth of the Axes border.     rgrid : array-like         Positions of the radial grid.      Returns     -------     ax : matplotlib.axes.Axes         The created Axes. # color from jet with alpha=0.6 # The actual visible background - extends a bit beyond the axis Create an axes in *fig* that contains 'matplotlib' as Text. # degrees Create the title slide.