Ejemplo n.º 1
0
def html(buildername='html'):
    """Build Sphinx 'html' target. """
    check_build()
    generate_frontpage_pngs()

    rc = '../lib/matplotlib/mpl-data/matplotlibrc'
    default_rc = os.path.join(matplotlib._get_data_path(), 'matplotlibrc')
    if not os.path.exists(rc) and os.path.exists(default_rc):
        rc = default_rc
    copy_if_out_of_date(rc, '_static/matplotlibrc')

    if small_docs:
        options = "-D plot_formats=png:100"
    else:
        options = ''
    if warnings_as_errors:
        options = options + ' -W'
    if os.system('sphinx-build -j %d %s -b %s -d build/doctrees . build/%s' % (
            n_proc, options, buildername, buildername)):
        raise SystemExit("Building HTML failed.")

    # Clean out PDF files from the _images directory
    for filename in glob.glob('build/%s/_images/*.pdf' % buildername):
        os.remove(filename)

    shutil.copy('../CHANGELOG', 'build/%s/_static/CHANGELOG' % buildername)
Ejemplo n.º 2
0
def html(buildername='html'):
    """Build Sphinx 'html' target. """
    check_build()
    fetch_depsy_badge()

    rc = '../lib/matplotlib/mpl-data/matplotlibrc'
    default_rc = os.path.join(matplotlib._get_data_path(), 'matplotlibrc')
    if not os.path.exists(rc) and os.path.exists(default_rc):
        rc = default_rc
    copy_if_out_of_date(rc, '_static/matplotlibrc')

    options = [
        '-j{}'.format(n_proc), '-b{}'.format(buildername), '-dbuild/doctrees'
    ]
    if small_docs:
        options += ['-Dplot_formats=png:100']
    if warnings_as_errors:
        options += ['-W']
    if subprocess.call(
        [sys.executable, '-msphinx', '.', 'build/{}'.format(buildername)] +
            options):
        raise SystemExit("Building HTML failed.")

    # Clean out PDF files from the _images directory
    for filename in glob.glob('build/%s/_images/*.pdf' % buildername):
        os.remove(filename)
Ejemplo n.º 3
0
def html(buildername='html'):
    """Build Sphinx 'html' target. """
    check_build()
    generate_frontpage_pngs()
    fetch_depsy_badge()

    rc = '../lib/matplotlib/mpl-data/matplotlibrc'
    default_rc = os.path.join(matplotlib._get_data_path(), 'matplotlibrc')
    if not os.path.exists(rc) and os.path.exists(default_rc):
        rc = default_rc
    copy_if_out_of_date(rc, '_static/matplotlibrc')

    if small_docs:
        options = "-D plot_formats=png:100"
    else:
        options = ''
    if warnings_as_errors:
        options = options + ' -W'
    if os.system('sphinx-build -j %d %s -b %s -d build/doctrees . build/%s' %
                 (n_proc, options, buildername, buildername)):
        raise SystemExit("Building HTML failed.")

    # Clean out PDF files from the _images directory
    for filename in glob.glob('build/%s/_images/*.pdf' % buildername):
        os.remove(filename)

    shutil.copy('../CHANGELOG', 'build/%s/_static/CHANGELOG' % buildername)
Ejemplo n.º 4
0
def html(buildername='html'):
    """Build Sphinx 'html' target. """
    check_build()
    fetch_depsy_badge()

    rc = '../lib/matplotlib/mpl-data/matplotlibrc'
    default_rc = os.path.join(matplotlib._get_data_path(), 'matplotlibrc')
    if not os.path.exists(rc) and os.path.exists(default_rc):
        rc = default_rc
    copy_if_out_of_date(rc, '_static/matplotlibrc')

    options = ['-j{}'.format(n_proc),
               '-b{}'.format(buildername),
               '-dbuild/doctrees']
    if small_docs:
        options += ['-Dplot_formats=png:100']
    if warnings_as_errors:
        options += ['-W']
    if subprocess.call(
            [sys.executable, '-msphinx', '.', 'build/{}'.format(buildername)]
            + options):
        raise SystemExit("Building HTML failed.")

    # Clean out PDF files from the _images directory
    for filename in glob.glob('build/%s/_images/*.pdf' % buildername):
        os.remove(filename)
Ejemplo n.º 5
0
def test_font_styles():
    from matplotlib import _get_data_path

    data_path = _get_data_path()

    def find_matplotlib_font(**kw):
        prop = FontProperties(**kw)
        path = findfont(prop, directory=data_path)
        return FontProperties(fname=path)

    from matplotlib.font_manager import FontProperties, findfont

    warnings.filterwarnings(
        "ignore",
        ("findfont: Font family \[u?'Foo'\] not found. Falling back to ."),
        UserWarning,
        module="matplotlib.font_manager",
    )

    plt.figure()
    ax = plt.subplot(1, 1, 1)

    normalFont = find_matplotlib_font(family="sans-serif", style="normal", variant="normal", size=14)
    ax.annotate("Normal Font", (0.1, 0.1), xycoords="axes fraction", fontproperties=normalFont)

    boldFont = find_matplotlib_font(family="Foo", style="normal", variant="normal", weight="bold", stretch=500, size=14)
    ax.annotate("Bold Font", (0.1, 0.2), xycoords="axes fraction", fontproperties=boldFont)

    boldItemFont = find_matplotlib_font(
        family="sans serif", style="italic", variant="normal", weight=750, stretch=500, size=14
    )
    ax.annotate("Bold Italic Font", (0.1, 0.3), xycoords="axes fraction", fontproperties=boldItemFont)

    lightFont = find_matplotlib_font(
        family="sans-serif", style="normal", variant="normal", weight=200, stretch=500, size=14
    )
    ax.annotate("Light Font", (0.1, 0.4), xycoords="axes fraction", fontproperties=lightFont)

    condensedFont = find_matplotlib_font(
        family="sans-serif", style="normal", variant="normal", weight=500, stretch=100, size=14
    )
    ax.annotate("Condensed Font", (0.1, 0.5), xycoords="axes fraction", fontproperties=condensedFont)

    ax.set_xticks([])
    ax.set_yticks([])
Ejemplo n.º 6
0
def test_font_styles():
    from matplotlib import _get_data_path
    data_path = _get_data_path()

    def find_matplotlib_font(**kw):
        prop = FontProperties(**kw)
        path = findfont(prop, directory=data_path)
        return FontProperties(fname=path)

    from matplotlib.font_manager import FontProperties, findfont
    warnings.filterwarnings('ignore', ('findfont: Font family \[u?\'Foo\'\] ' +
                                       'not found. Falling back to .'),
                            UserWarning,
                            module='matplotlib.font_manager')
    fig = plt.figure()
    ax = plt.subplot(1, 1, 1)

    normalFont = find_matplotlib_font(
        family="sans-serif",
        style="normal",
        variant="normal",
        size=14,
    )
    ax.annotate("Normal Font", (0.1, 0.1),
                xycoords='axes fraction',
                fontproperties=normalFont)

    boldFont = find_matplotlib_font(
        family="Foo",
        style="normal",
        variant="normal",
        weight="bold",
        stretch=500,
        size=14,
    )
    ax.annotate("Bold Font", (0.1, 0.2),
                xycoords='axes fraction',
                fontproperties=boldFont)

    boldItemFont = find_matplotlib_font(
        family="sans serif",
        style="italic",
        variant="normal",
        weight=750,
        stretch=500,
        size=14,
    )
    ax.annotate("Bold Italic Font", (0.1, 0.3),
                xycoords='axes fraction',
                fontproperties=boldItemFont)

    lightFont = find_matplotlib_font(
        family="sans-serif",
        style="normal",
        variant="normal",
        weight=200,
        stretch=500,
        size=14,
    )
    ax.annotate("Light Font", (0.1, 0.4),
                xycoords='axes fraction',
                fontproperties=lightFont)

    condensedFont = find_matplotlib_font(
        family="sans-serif",
        style="normal",
        variant="normal",
        weight=500,
        stretch=100,
        size=14,
    )
    ax.annotate("Condensed Font", (0.1, 0.5),
                xycoords='axes fraction',
                fontproperties=condensedFont)

    ax.set_xticks([])
    ax.set_yticks([])
Ejemplo n.º 7
0
#Once the conda-forge channel has been enabled, matplotlib, matplotlib-base, mpl_sample_data can be installed with:

conda install matplotlib matplotlib-base mpl_sample_data
#It is possible to list all of the versions of matplotlib available on your platform with:

conda search matplotlib --channel conda-forge
"""

years = mdates.YearLocator()  # every year
months = mdates.MonthLocator()  # every month
yearsFmt = mdates.DateFormatter('%Y')

# Load a numpy record array from yahoo csv data with fields date, open, close,
# volume, adj_close from the mpl-data/example directory. The record array
# stores the date as an np.datetime64 with a day unit ('D') in the date column.
with open(os.path.join(matplotlib._get_data_path(), 'sample_data/goog.npz'),
          mode='rb') as datafile:
    r = np.load(datafile)['price_data'].view(np.recarray)

with open(os.path.join(matplotlib._get_data_path(), 'sample_data/aapl.npz'),
          mode='rb') as datafile:
    r2 = np.load(datafile)['price_data'].view(np.recarray)

fig, ax = plt.subplots()
ax.plot(r.date, r.adj_close)
ax.plot(r2.date, r2.adj_close)

# format the ticks
ax.xaxis.set_major_locator(years)
ax.xaxis.set_major_formatter(yearsFmt)
ax.xaxis.set_minor_locator(months)