def formatter():
    """
    Create slide for feature highlight of simplified tick formatters.
    """

    fig = new_slide()

    slide_heading(fig, '3.3 Feature: simplified tick formatters')

    fig.text(
        0.05, 0.8, """\
ax.xaxis.set_major_formatter(
    StrMethodFormatter('{x} km'))
\N{Rightwards Double Arrow} ax.xaxis.set_major_formatter('{x} km')
    """, **CODE)

    fig.text(
        0.05, 0.5, """\
def fmt(x, pos):
    return f'{x} km'

ax.xaxis.set_major_formatter(FuncFormatter(fmt))
\N{Rightwards Double Arrow} ax.xaxis.set_major_formatter(fmt)
    """, **CODE)

    annotate_pr_author(fig, 'toddrjen', pr=16715)

    return fig
def axline():
    """
    Create slide for feature highlight of axline.
    """

    fig = new_slide()

    slide_heading(fig, '3.3 Feature: axline for infinite lines')

    fig.text(
        0.05, 0.8, """\
fig, ax = plt.subplots()
ax.axline((0.1, 0.1), slope=5, color='C0')
ax.axline((0.1, 0.2), (0.8, 0.7), color='C3')
    """, **CODE)

    ax = fig.add_axes((0.1, 0.1, 0.8, 0.5))

    ax.axline((0.1, 0.1), slope=5, color='C0', lw=3, label='by slope')
    ax.axline((0.1, 0.2), (0.8, 0.7), color='C3', lw=3, label='by points')

    ax.legend()

    annotate_pr_author(fig,
                       'QuLogic',
                       'dstansby',
                       'anntzer',
                       'timhoffm',
                       pr=15330)

    return fig
Beispiel #3
0
def docs():
    fig = new_slide()

    slide_heading(fig, 'Documentation')

    props = dict(fontproperties=FONT,
                 fontsize=56,
                 alpha=0.7,
                 verticalalignment='top')

    fig.text(0.05, 0.8, 'Large and ongoing documentation rewrite', **props)
    fig.text(0.1, 0.8, f'\n{BULLET} Refreshed homepage', **props)
    fig.text(0.1, 0.8, f'\n\n{BULLET} 323 Pull Requests in 3.3 alone', **props)

    fig.text(0.05, 0.5, "3.3 What's New?", **props)
    t = fig.text(0.1, 0.5,
                 '\nhttps://matplotlib.org/3.3.0/users/whats_new.html',
                 **props)
    t.set_url('https://matplotlib.org/3.3.0/users/whats_new.html')

    fig.text(0.05, 0.3, 'Cheatsheets! By @rougier', **props)
    t = fig.text(0.1, 0.3, '\nhttps://github.com/matplotlib/cheatsheets/',
                 **props)
    t.set_url('https://github.com/matplotlib/cheatsheets/')

    return fig
def slides(mpl_path):
    """
    Create slide for release history.

    Parameters
    ----------
    mpl_path : str or pathlib.Path
        Path to the Matplotlib checkout used to find release tags and dates.
    """
    fig = new_slide()

    slide_heading(fig, 'Release History')

    tags = subprocess.run(['git', 'tag', '-l',
                           '--format=%(refname:strip=2) %(creatordate:short)'],
                          cwd=mpl_path, capture_output=True, text=True)
    dates = []
    names = []
    for item in tags.stdout.splitlines():
        tag_name, date = item.split(' ', 1)
        if 'rc' not in tag_name and 'b' not in tag_name:
            dates.append(datetime.fromisoformat(date))
            names.append(tag_name)

    levels = np.tile([-5, 5, -3, 3, -1, 1],
                     int(np.ceil(len(dates) / 6)))[:len(dates)]

    ax = fig.add_axes((0.05, 0.11, 0.9, 0.7))

    ax.vlines(dates, 0, levels, color="tab:red", linewidth=3)
    ax.plot(dates, np.zeros_like(dates), "-o",
            color="k", markerfacecolor="w", linewidth=3, markersize=10)

    # Annotate lines.
    for d, l, r in zip(dates, levels, names):
        ax.annotate(r, xy=(d, l),
                    xytext=(-3, np.sign(l)*3), textcoords="offset points",
                    horizontalalignment="right",
                    verticalalignment="bottom" if l > 0 else "top",
                    fontsize=24)

    # Format xaxis with 4 month intervals.
    ax.get_xaxis().set_major_locator(mdates.MonthLocator(interval=4))
    ax.get_xaxis().set_major_formatter(mdates.DateFormatter("%b %Y"))
    plt.setp(ax.get_xticklabels(), rotation=30, ha="right", fontsize=24)

    # Remove y axis and spines.
    ax.get_yaxis().set_visible(False)
    for spine in ["left", "top", "right"]:
        ax.spines[spine].set_visible(False)

    ax.margins(y=0.1)

    # Annotate range between SciPy 2019 and SciPy 2020.
    ax.axvspan(datetime(2019, 7, 8), datetime(2020, 7, 6), alpha=0.5)

    # Only plot the last 5 years before SciPy 2020.
    ax.set_xlim(datetime(2015, 7, 6), datetime(2020, 7, 6))

    return fig
Beispiel #5
0
def slides():
    """
    Create slide for future plans.
    """
    fig = new_slide()

    slide_heading(fig, 'Future Plans')

    props = dict(fontproperties=FONT, fontsize=56, alpha=0.7,
                 verticalalignment='top')

    fig.text(0.05, 0.8, 'Next feature release: 3.4', **props)
    fig.text(0.1, 0.7, f'{BULLET} September 2020', **props)
    fig.text(0.1, 0.6,
             f'{BULLET} Dropping support for Python 3.6 & NumPy 1.15',
             **props)

    fig.text(0.05, 0.4, 'Google Season of Docs 2020', **props)

    fig.text(0.05, 0.2, 'Check out our blog!', **props)
    t = fig.text(0.1, 0.2, '\nhttps://matplotlib.org/matplotblog/',
                 **props)
    t.set_url('https://matplotlib.org/matplotblog/')

    return fig
def sharing():
    """
    Create slide for feature highlight of post-hoc Axes sharing.
    """

    fig = new_slide()

    slide_heading(fig, '3.3 Feature: post-hoc Axes sharing')

    fig.text(
        0.05, 0.8, """\
axd['histx'].sharex(axd['scat'])
axd['histy'].sharey(axd['scat'])""", **CODE)

    np.random.seed(0)
    x = np.random.random(100) * 100 + 20
    y = np.random.random(100) * 50 + 25
    c = np.random.random(100) - 0.5

    with plt.rc_context({'xtick.labelsize': 20, 'ytick.labelsize': 20}):
        axd = fig.subplot_mosaic(
            [['.', 'histx'], ['histy', 'scat']],
            gridspec_kw={
                'width_ratios': [1, 7],
                'height_ratios': [2, 7],
                # Don't overlay title and code.
                'top': 0.65
            })

        im = axd['scat'].scatter(x, y, c=c, cmap='RdBu', picker=True)
        fig.colorbar(
            im,
            orientation='horizontal',
            # Semantically, the colorbar isn't really related to
            # 'histy', but since we can't use constrained layout in
            # the slides, we add it anyway to make things shrink
            # correctly.
            ax=[axd['scat'], axd['histy']],
            # Since we're stealing space from the 'histy' Axes as
            # well, re-jigger the size and anchoring so that it only
            # appears under the 'scat' Axes.
            shrink=0.8,
            anchor=(1, 1),
            panchor=(1, 0),
            aspect=50)

        _, _, patchesx = axd['histx'].hist(x)
        _, _, patchesy = axd['histy'].hist(y, orientation='horizontal')

    axd['histy'].invert_xaxis()
    axd['histx'].sharex(axd['scat'])
    axd['histy'].sharey(axd['scat'])

    annotate_pr_author(fig, 'anntzer', pr=15287)

    return fig
Beispiel #7
0
def slides():
    """
    Create end slide.
    """
    fig = new_slide()

    slide_heading(fig, 'Thank You!')

    props = dict(fontproperties=FONT,
                 fontsize=56,
                 alpha=0.7,
                 horizontalalignment='center')

    fig.text(0.5, 0.5, 'This entire presentation was made in Matplotlib:',
             **props)

    t = fig.text(0.5, 0.4, '\nhttps://github.com/QuLogic/scipy2020-mpl-update',
                 **props)
    t.set_url('https://github.com/QuLogic/scipy2020-mpl-update')

    return fig
def feature32_bar3d():
    """
    Create slide for feature highlight of bar3d light source.
    """

    fig = new_slide()

    slide_heading(fig, '3.2 Feature: bar3d light source')

    # Plot two different light source angles.
    for i, angle in [(1, 90), (2, 0)]:
        # This example comes from the Pull Request adding this support:
        # https://github.com/matplotlib/matplotlib/pull/15099#issuecomment-523981989
        ax = fig.add_subplot(1, 2, i, projection="3d")

        ls = mcolors.LightSource(azdeg=45, altdeg=angle)
        cmap = plt.get_cmap("coolwarm")

        length, width = 3, 4
        area = length * width

        norm = mcolors.Normalize(0, area-1)

        x, y = np.meshgrid(np.arange(length), np.arange(width))
        x = x.ravel()
        y = y.ravel()
        dz = x + y

        color = cmap(norm(np.arange(area)))

        ax.bar3d(x=x, y=y, z=0,
                 dx=1, dy=1, dz=dz,
                 color=color, shade=True, lightsource=ls)

    annotate_pr_author(fig, 'fourpoints', pr=15099)

    return fig
def mosaic():
    """
    Create slide for feature highlight of subplot_mosaic.
    """

    example1 = """
    '''
    A.C
    BBB
    .D.
    '''"""
    example2 = """[
    ['.', 'histx'],
    ['histy', 'scat'],
]"""

    for text in [example1, example2]:
        fig = new_slide()

        slide_heading(fig, '3.3 Feature: subplot_mosaic')

        fig.text(0.05, 0.8, f'plt.figure().subplot_mosaic({text})', **CODE)

        ax_dict = fig.subplot_mosaic(
            eval(text.lstrip()),
            # Don't overlay title and code.
            gridspec_kw={
                'left': 0.3,
                'top': 0.7,
                'right': 0.97
            })
        identify_axes(ax_dict)

        annotate_pr_author(fig, 'tacaswell', pr=16603)

        yield fig
Beispiel #10
0
def slides():
    """
    Create slide for general news.
    """
    fig = new_slide()

    slide_heading(fig, 'General News')

    level1 = partial(bullet_level1, fig)
    level2 = partial(bullet_level2, fig)

    t = level1(0.8, f'{BULLET} Chan Zuckerberg Institute grant')
    t.set_url('https://matplotlib.org/matplotblog/posts/matplotlib-rsef/')
    level1(0.8, '\n    \N{EM dash} Essential Open Source Software for Science')

    level2(0.8,
           '\n\nThomas Caswell, Hannah Aizenman,\nElliott Sales de Andrade')

    t = level1(0.5, f'{BULLET} Google Summer of Code')
    t.set_url(
        'https://matplotlib.org/matplotblog/posts/introductory-gsoc2020-post/')

    level2(0.5,
           '\nSidharth Bansal \N{EM dash} test baseline images relocation')

    level1(0.35, f'{BULLET} Discourse')

    t = level2(0.35, '\nhttps://discourse.matplotlib.org/')
    t.set_url('https://discourse.matplotlib.org/')

    level1(0.2, f'{BULLET} PyPI classifier')

    t = level2(0.2, '\nFramework :: Matplotlib')
    t.set_url('https://pypi.org/search/?c=Framework+%3A%3A+Matplotlib')

    return fig