Note

Click here to download the full example code

Link to other packagesΒΆ

Use sphinx_gallery to link to other packages, like numpy, matplotlib.colors, and matplotlib.pyplot.

FYI this gallery uses sphinx_gallery.sorting.FileNameSortKey.

../_images/sphx_glr_plot_numpy_matplotlib_001.png

Out:

True
/home/lucy/Documents/sphinx-gallery/sphinx_gallery/tests/tinybuild/examples/plot_numpy_matplotlib.py:37: RuntimeWarning: This warning should show up in the output
  warn('This warning should show up in the output', RuntimeWarning)
Property

from warnings import warn

import numpy as np
from matplotlib.colors import is_color_like
from matplotlib.figure import Figure
from itertools import compress  # noqa
import matplotlib
import matplotlib.pyplot as plt
import sphinx_gallery.backreferences

from local_module import N  # N = 1000

t = np.arange(N) / float(N)
win = np.hanning(N)
print(is_color_like('r'))
fig, ax = plt.subplots()
ax.plot(t, win, color='r')
ax.text(0, 1, 'png', size=40, va='top')
fig.tight_layout()
orig_dpi = 80. if matplotlib.__version__[0] < '2' else 100.
assert plt.rcParams['figure.dpi'] == orig_dpi
plt.rcParams['figure.dpi'] = 70.
assert plt.rcParams['figure.dpi'] == 70.
listy = [0, 1]
compress('abc', [0, 0, 1])
warn('This warning should show up in the output', RuntimeWarning)
x = Figure()  # plt.Figure should be decorated (class), x shouldn't (inst)
# nested resolution resolves to numpy.random.mtrand.RandomState:
rng = np.random.RandomState(0)
# test Issue 583
sphinx_gallery.backreferences.identify_names([('text', 'Text block', 1)])
# 583: methods don't link properly
dc = sphinx_gallery.backreferences.DummyClass()
dc.run()
print(dc.prop)

Total running time of the script: ( 0 minutes 0.145 seconds)

Download Python source code: plot_numpy_matplotlib.py

Download Jupyter notebook: plot_numpy_matplotlib.ipynb

Gallery generated by Sphinx-Gallery

Python

Navigation

  • sphinx_gallery.gen_gallery
  • sphinx_gallery.backreferences
  • sphinx_gallery.gen_rst
  • sphinx_gallery.py_source_parser
  • sphinx_gallery.docs_resolv
  • sphinx_gallery.notebook
  • sphinx_gallery.downloads
  • sphinx_gallery.docs_resolv
  • sphinx_gallery.sorting
  • Gallery of Examples
    • SVG graphics
    • Pickling
    • Testing future statements across examples
    • Link to other packages
  • Future examples

Related Topics

  • Documentation overview
    • Gallery of Examples
      • Previous: Testing future statements across examples
      • Next: Test without __future__ imports

Quick search

©. | Powered by Sphinx 2.2.2 & Alabaster 0.7.12 | Page source