diff --git a/INSTALL b/INSTALL
index fb2412fd8962..40e29470e793 100644
--- a/INSTALL
+++ b/INSTALL
@@ -1,6 +1,7 @@
.. The source of this document is INSTALL. During the doc build process,
.. this file is copied over to doc/users/installing.rst.
.. Therefore, you must edit INSTALL, *not* doc/users/installing.rst!
+.. _pip: https://pypi.python.org/pypi/pip/
**********
Installing
@@ -21,14 +22,12 @@ Most platforms : scientific Python distributions
The first option is to use one of the pre-packaged python
distributions that already provide matplotlib built-in. The
Continuum.io Python distribution (`Anaconda
-`_ or `miniconda
+`_ or `miniconda
`_) and the Enthought
distribution `(Canopy) `_
are both excellent choices that "just work" out of the box for
Windows, OSX and common Linux platforms. Both of these distributions
-include matplotlib and *lots* of other useful tools. Another
-excellent alternative for Windows users is `Python (x, y)
-`_ .
+include matplotlib and *lots* of other useful tools.
Linux : using your package manager
@@ -44,9 +43,10 @@ Mac OSX : using pip
-------------------
If you are on Mac OSX you can probably install matplotlib binaries using the
-standard Python installation program `pip `_.
+standard Python installation program pip_.
See :ref:`install_osx_binaries`.
+.. _installing_windows:
Windows
-------
@@ -54,33 +54,25 @@ Windows
If you don't already have Python installed, we recommend using
one of the `scipy-stack compatible Python distributions
`_ such as WinPython, Python(x,y),
-Enthought Canopy, or Continuum Anaconda, which have matplotlib and
-many of its dependencies, plus other useful packages, preinstalled.
-
-For `standard Python `_ installations
-you will also need to install compatible versions of
-`setuptools `_,
-`numpy `_,
-`python-dateutil `_,
-`pytz `_,
-`pyparsing `_, and
-`cycler `_
-in addition to
-`matplotlib `_.
-
-For Python 3.5 the `Visual C++ Redistributable for Visual Studio 2015
-`_
-needs to be installed.
-In case Python 2.7 to 3.4 are not installed for all users (not the default),
+Enthought Canopy, or Continuum Anaconda, which have matplotlib and many
+of its dependencies, plus other useful packages, preinstalled.
+
+For `standard Python `_ installations,
+install matplotlib using pip_::
+
+ python -m pip install -U pip setuptools
+ python -m pip install matplotlib
+
+In case Python 2.7 or 3.4 are not installed for all users,
the Microsoft Visual C++ 2008 (
`64 bit `__
or
`32 bit `__
-for Python 2.7 to 3.2) or Microsoft Visual C++ 2010 (
+for Python 2.7) or Microsoft Visual C++ 2010 (
`64 bit `__
or
`32 bit `__
-for Python 3.3 and 3.4) redistributable packages need to be installed.
+for Python 3.4) redistributable packages need to be installed.
Matplotlib depends on `Pillow `_
for reading and saving JPEG, BMP, and TIFF image files.
@@ -105,22 +97,23 @@ For other backends you may need to install
or GhostScript.
TkAgg is probably the best backend for interactive use from the
-standard Python shell or IPython. It is enabled as the default backend
+standard Python shell or IPython. It is enabled as the default backend
for the official binaries. GTK3 is not supported on Windows.
-The Windows installers (:file:`*.exe`) and wheels (:file:`*.whl`) on
-the `PyPI download page `_ do
-not contain test data or example code. If you want to try the many
-demos that come in the matplotlib source distribution, download the
-:file:`*.tar.gz` file and look in the :file:`examples` subdirectory.
-To run the test suite, copy the :file:`lib\matplotlib\tests` and
-:file:`lib\mpl_toolkits\tests` directories from the source
-distribution to :file:`sys.prefix\Lib\site-packages\matplotlib` and
-:file:`sys.prefix\Lib\site-packages\mpl_toolkits` respectively, and
+The Windows wheels (:file:`*.whl`) on the `PyPI download page
+`_ do not contain test data
+or example code.
+If you want to try the many demos that come in the matplotlib source
+distribution, download the :file:`*.tar.gz` file and look in the
+:file:`examples` subdirectory.
+To run the test suite, copy the :file:`lib\\matplotlib\\tests` and
+:file:`lib\\mpl_toolkits\\tests` directories from the source
+distribution to :file:`sys.prefix\\Lib\\site-packages\\matplotlib` and
+:file:`sys.prefix\\Lib\\site-packages\\mpl_toolkits` respectively, and
install `nose `_, `mock
`_, Pillow, MiKTeX, GhostScript,
ffmpeg, avconv, mencoder, ImageMagick, and `Inkscape
-`_.
+`_.
@@ -327,17 +320,14 @@ git repository and follow the instruction in :file:`README.osx`.
.. _build_windows:
-
Building on Windows
-------------------
The Python shipped from http://www.python.org is compiled with Visual Studio
-2008 for versions before 3.3 and Visual Studio 2010 for 3.3 and later. Python
-extensions are recommended to be compiled with the same compiler. The .NET
-Framework 4.0 is required for MSBuild (you'll likely have the requisite
-Framework with Visual Studio). In addition to Visual Studio `CMake
-`_ is required for building libpng.
-
-Since there is no canonical Windows package manager the build methods for
-freetype, zlib, libpng, tcl, & tk source code are documented as a build script
+2008 for versions before 3.3, Visual Studio 2010 for 3.3 and 3.4, and
+Visual Studio 2015 for 3.5. Python extensions are recommended to be compiled
+with the same compiler.
+
+Since there is no canonical Windows package manager, the methods for building
+freetype, zlib, and libpng from source code are documented as a build script
at `matplotlib-winbuild `_.
diff --git a/doc/_static/logo2.png b/doc/_static/logo2.png
new file mode 100644
index 000000000000..72843ab1febb
Binary files /dev/null and b/doc/_static/logo2.png differ
diff --git a/doc/_templates/index.html b/doc/_templates/index.html
index 3f3c4a16152d..9b1989c068ef 100644
--- a/doc/_templates/index.html
+++ b/doc/_templates/index.html
@@ -65,7 +65,7 @@ Introduction
You can generate plots, histograms, power spectra, bar charts,
errorcharts, scatterplots, etc, with just a few lines of code.
For a sampling, see the screenshots, thumbnail gallery, and
- examples directory
+ examples directory
For simple plotting the pyplot interface provides a
MATLAB-like interface, particularly when combined
@@ -102,9 +102,7 @@
John Hunter (1968-2012)
Installation
- Visit the
- matplotlib
- installation instructions..
+ Visit the matplotlib installation instructions.
Documentation
@@ -116,8 +114,8 @@ Documentation
Trying to learn how to do a particular kind of plot? Check out
- the gallery, examples,
- or the list of plotting
+ the gallery, examples,
+ or the list of plotting
commands.
Other learning resources
diff --git a/doc/_templates/layout.html b/doc/_templates/layout.html
index 46cdcecaa88d..ad1c55a25161 100644
--- a/doc/_templates/layout.html
+++ b/doc/_templates/layout.html
@@ -168,8 +168,11 @@ {{ _('Navigation') }}
-

+{%- if builder in ('htmlhelp', 'devhelp', 'latex') %}
+

+{%- else %}
+

+{%- endif %}
{% endblock %}
diff --git a/doc/faq/installing_faq.rst b/doc/faq/installing_faq.rst
index 9de7ab2598ed..3b38a9458cfa 100644
--- a/doc/faq/installing_faq.rst
+++ b/doc/faq/installing_faq.rst
@@ -52,31 +52,6 @@ matplotlib was originally installed on your system. Follow the steps
below that goes with your original installation method to cleanly
remove matplotlib from your system.
-Easy Install
-------------
-
-1. Delete the caches from your :ref:`.matplotlib configuration directory
- `.
-
-2. Run::
-
- easy_install -m matplotlib
-
-
-3. Delete any .egg files or directories from your :ref:`installation
- directory `.
-
-
-
-Windows installer
------------------
-
-1. Delete the caches from your :ref:`.matplotlib configuration directory
- `.
-
-2. Use :menuselection:`Start --> Control Panel` to start the :program:`Add and
- Remove Software` utility.
-
Source install
--------------
@@ -374,24 +349,4 @@ know: see :ref:`reporting-problems`.
Windows Notes
=============
-We recommend you use one of the excellent python collections which include
-Python itself and a wide range of libraries including matplotlib:
-
-- Anaconda_ from `Continuum Analytics`_
-- Canopy_ from Enthought_
-- `Python (x, y) `_
-
-Python (X, Y) is Windows-only, whereas Anaconda and Canopy are cross-platform.
-
-.. _windows-installers:
-
-Standalone binary installers for Windows
-----------------------------------------
-
-If you have already installed Python and numpy, you can use one of the
-matplotlib binary installers for windows -- you can get these from the
-`the PyPI matplotlib page `_
-site. Choose the files with an ``.exe`` extension that match your
-version of Python (e.g., ``py2.7`` if you installed Python 2.7). If
-you haven't already installed Python, you can get the official version
-from the `Python web site `_.
+See :ref:`installing_windows`.
diff --git a/examples/color/named_colors.py b/examples/color/named_colors.py
index 232b514eda30..2280e6ea18bb 100644
--- a/examples/color/named_colors.py
+++ b/examples/color/named_colors.py
@@ -27,7 +27,7 @@
ncols = 4
nrows = int(np.ceil(1. * n / ncols))
-fig, ax = plt.subplots()
+fig, ax = plt.subplots(figsize=(8, 5))
X, Y = fig.get_dpi() * fig.get_size_inches()
@@ -49,10 +49,6 @@
horizontalalignment='left',
verticalalignment='center')
- # Add extra black line a little bit thicker to make
- # clear colors more visible.
- ax.hlines(
- y, xi_line, xf_line, color='black', linewidth=(h * 0.7))
ax.hlines(
y + h * 0.1, xi_line, xf_line, color=colors[name], linewidth=(h * 0.6))
diff --git a/examples/pylab_examples/csd_demo.py b/examples/pylab_examples/csd_demo.py
index fc925a67028e..3e2fe072eec3 100644
--- a/examples/pylab_examples/csd_demo.py
+++ b/examples/pylab_examples/csd_demo.py
@@ -4,8 +4,10 @@
import numpy as np
import matplotlib.pyplot as plt
+
+fig, (ax1, ax2) = plt.subplots(2, 1)
# make a little extra space between the subplots
-plt.subplots_adjust(wspace=0.5)
+fig.subplots_adjust(hspace=0.5)
dt = 0.01
t = np.arange(0, 30, dt)
@@ -20,14 +22,12 @@
s1 = 0.01*np.sin(2*np.pi*10*t) + cnse1
s2 = 0.01*np.sin(2*np.pi*10*t) + cnse2
-plt.subplot(211)
-plt.plot(t, s1, t, s2)
-plt.xlim(0, 5)
-plt.xlabel('time')
-plt.ylabel('s1 and s2')
-plt.grid(True)
+ax1.plot(t, s1, t, s2)
+ax1.set_xlim(0, 5)
+ax1.set_xlabel('time')
+ax1.set_ylabel('s1 and s2')
+ax1.grid(True)
-plt.subplot(212)
-cxy, f = plt.csd(s1, s2, 256, 1./dt)
-plt.ylabel('CSD (db)')
+cxy, f = ax2.csd(s1, s2, 256, 1./dt)
+ax2.set_ylabel('CSD (db)')
plt.show()
diff --git a/examples/showcase/bachelors_degrees_by_gender.py b/examples/showcase/bachelors_degrees_by_gender.py
index c0ea4045ef3c..737c37dd8f59 100644
--- a/examples/showcase/bachelors_degrees_by_gender.py
+++ b/examples/showcase/bachelors_degrees_by_gender.py
@@ -27,10 +27,12 @@
ax.get_xaxis().tick_bottom()
ax.get_yaxis().tick_left()
+fig.subplots_adjust(left=.06, right=.75, bottom=.02, top=.94)
# Limit the range of the plot to only where the data is.
# Avoid unnecessary whitespace.
-plt.xlim(1968.5, 2011.1)
-plt.ylim(-0.25, 90)
+ax.set_xlim(1968.5, 2011.1)
+ax.set_ylim(-0.25, 90)
+ax.get_xaxis().get_major_formatter().set_useOffset(False)
# Make sure your axis ticks are large enough to be easily read.
# You don't want your viewers squinting to read your plot.
@@ -91,10 +93,10 @@
# Note that if the title is descriptive enough, it is unnecessary to include
# axis labels; they are self-evident, in this plot's case.
-plt.title('Percentage of Bachelor\'s degrees conferred to women in '
- 'the U.S.A. by major (1970-2011)\n', fontsize=18, ha='center')
+fig.suptitle('Percentage of Bachelor\'s degrees conferred to women in '
+ 'the U.S.A. by major (1970-2011)\n', fontsize=18, ha='center')
# Finally, save the figure as a PNG.
# You can also save it as a PDF, JPEG, etc.
# Just change the file extension in this call.
-plt.savefig('percent-bachelors-degrees-women-usa.png', bbox_inches='tight')
+# plt.savefig('percent-bachelors-degrees-women-usa.png', bbox_inches='tight')
diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py
index 789e0af399e3..64cc3f86c0c7 100644
--- a/lib/matplotlib/axes/_axes.py
+++ b/lib/matplotlib/axes/_axes.py
@@ -635,63 +635,13 @@ def text(self, x, y, s, fontdict=None,
@docstring.dedent_interpd
def annotate(self, *args, **kwargs):
- """
- Create an annotation: a piece of text referring to a data
- point.
-
- Parameters
- ----------
- s : string
- label
-
- xy : (x, y)
- position of element to annotate. See *xycoords* to control what
- coordinate system this value is interpretated in.
-
- xytext : (x, y) , optional, default: None
- position of the label `s`. See *textcoords* to control what
- coordinate system this value is interpreted in.
-
- xycoords : string, optional, default: "data"
- string that indicates what type of coordinates `xy` is. Examples:
- "figure points", "figure pixels", "figure fraction", "axes
- points", .... See `matplotlib.text.Annotation` for more details.
-
- textcoords : string, optional, default: None
- string that indicates what type of coordinates `text` is. Examples:
- "figure points", "figure pixels", "figure fraction", "axes
- points", .... See `matplotlib.text.Annotation` for more details.
-
- arrowprops : `matplotlib.lines.Line2D` properties, optional
- Dictionary of line properties for the arrow that connects
- the annotation to the point. If the dictionnary has a key
- `arrowstyle`, a `~matplotlib.patches.FancyArrowPatch`
- instance is created and drawn. See
- `matplotlib.text.Annotation` for more details on valid
- options. Default is None.
-
- Returns
- -------
- a : `~matplotlib.text.Annotation`
-
-
- Notes
- -----
-
- %(Annotation)s
-
- Examples
- --------
-
- .. plot:: mpl_examples/pylab_examples/annotation_demo2.py
- """
a = mtext.Annotation(*args, **kwargs)
a.set_transform(mtransforms.IdentityTransform())
if 'clip_on' in kwargs:
a.set_clip_path(self.patch)
self._add_text(a)
return a
-
+ annotate.__doc__ = mtext.Annotation.__init__.__doc__
#### Lines and spans
@docstring.dedent_interpd
diff --git a/lib/matplotlib/backends/backend_gdk.py b/lib/matplotlib/backends/backend_gdk.py
index 3a22f6b331c5..a9c89c43e40b 100644
--- a/lib/matplotlib/backends/backend_gdk.py
+++ b/lib/matplotlib/backends/backend_gdk.py
@@ -472,8 +472,8 @@ def _print_image(self, filename, format, *args, **kwargs):
# http://www.pygtk.org/docs/pygtk/class-gdkpixbuf.html#method-gdkpixbuf--save
options = restrict_dict(kwargs, ['quality'])
if format in ['jpg','jpeg']:
- if 'quality' not in options:
- options['quality'] = rcParams['savefig.jpeg_quality']
- options['quality'] = str(options['quality'])
+ if 'quality' not in options:
+ options['quality'] = rcParams['savefig.jpeg_quality']
+ options['quality'] = str(options['quality'])
pixbuf.save(filename, format, options=options)
diff --git a/lib/matplotlib/backends/backend_gtk.py b/lib/matplotlib/backends/backend_gtk.py
index 482f30c91206..41716097c620 100644
--- a/lib/matplotlib/backends/backend_gtk.py
+++ b/lib/matplotlib/backends/backend_gtk.py
@@ -472,10 +472,10 @@ def _print_image(self, filename, format, *args, **kwargs):
# http://www.pygtk.org/docs/pygtk/class-gdkpixbuf.html#method-gdkpixbuf--save
options = cbook.restrict_dict(kwargs, ['quality'])
if format in ['jpg','jpeg']:
- if 'quality' not in options:
- options['quality'] = rcParams['savefig.jpeg_quality']
+ if 'quality' not in options:
+ options['quality'] = rcParams['savefig.jpeg_quality']
- options['quality'] = str(options['quality'])
+ options['quality'] = str(options['quality'])
if is_string_like(filename):
try:
diff --git a/lib/matplotlib/cbook.py b/lib/matplotlib/cbook.py
index 5f4db526fdd9..76d5d733a5dd 100644
--- a/lib/matplotlib/cbook.py
+++ b/lib/matplotlib/cbook.py
@@ -917,10 +917,10 @@ class Xlator(dict):
"Perl" : "Python",
}
- print multiple_replace(adict, text)
+ print(multiple_replace(adict, text))
xlat = Xlator(adict)
- print xlat.xlat(text)
+ print(xlat.xlat(text))
"""
def _make_regex(self):
diff --git a/lib/matplotlib/tests/test_streamplot.py b/lib/matplotlib/tests/test_streamplot.py
index b34906d632cb..d5c688ae2992 100644
--- a/lib/matplotlib/tests/test_streamplot.py
+++ b/lib/matplotlib/tests/test_streamplot.py
@@ -27,7 +27,8 @@ def test_startpoints():
plt.plot(start_x, start_y, 'ok')
-@image_comparison(baseline_images=['streamplot_colormap'])
+@image_comparison(baseline_images=['streamplot_colormap'],
+ tol=0.002)
def test_colormap():
X, Y, U, V = velocity_field()
plt.streamplot(X, Y, U, V, color=U, density=0.6, linewidth=2,
diff --git a/lib/matplotlib/tests/test_transforms.py b/lib/matplotlib/tests/test_transforms.py
index b804219a4e79..1498283db573 100644
--- a/lib/matplotlib/tests/test_transforms.py
+++ b/lib/matplotlib/tests/test_transforms.py
@@ -82,7 +82,8 @@ def _as_mpl_transform(self, axes):
mtrans.Affine2D().scale(10).get_matrix())
-@image_comparison(baseline_images=['pre_transform_data'])
+@image_comparison(baseline_images=['pre_transform_data'],
+ tol=0.08)
def test_pre_transform_plotting():
# a catch-all for as many as possible plot layouts which handle
# pre-transforming the data NOTE: The axis range is important in this
diff --git a/lib/matplotlib/text.py b/lib/matplotlib/text.py
index 92d3f067a525..2e4957a3e7fa 100644
--- a/lib/matplotlib/text.py
+++ b/lib/matplotlib/text.py
@@ -1662,17 +1662,45 @@ def set_figure(self, fig):
class OffsetFrom(object):
+ 'Callable helper class for working with `Annotation`'
def __init__(self, artist, ref_coord, unit="points"):
+ '''
+ Parameters
+ ----------
+ artist : `Artist`, `BboxBase`, or `Transform`
+ The object to compute the offset from.
+
+ ref_coord : length 2 sequence
+ If `artist` is an `Artist` or `BboxBase`, this values is
+ the location to of the offset origin in fractions of the
+ `artist` bounding box.
+
+ If `artist` is a transform, the offset origin is the
+ transform applied to this value.
+
+ unit : {'points, 'pixels'}
+ The screen units to use (pixels or points) for the offset
+ input.
+
+ '''
self._artist = artist
self._ref_coord = ref_coord
self.set_unit(unit)
def set_unit(self, unit):
+ '''
+ The unit for input to the transform used by ``__call__``
+
+ Parameters
+ ----------
+ unit : {'points', 'pixels'}
+ '''
if unit not in ["points", "pixels"]:
raise ValueError("'unit' must be one of [ 'points' | 'pixels' ]")
self._unit = unit
def get_unit(self):
+ 'The unit for input to the transform used by ``__call__``'
return self._unit
def _get_scale(self, renderer):
@@ -1683,6 +1711,20 @@ def _get_scale(self, renderer):
return renderer.points_to_pixels(1.)
def __call__(self, renderer):
+ '''
+ Return the offset transform.
+
+ Parameters
+ ----------
+ renderer : `RendererBase`
+ The renderer to use to compute the offset
+
+ Returns
+ -------
+ transform : `Transform`
+ Maps (x, y) in pixel or point units to screen units
+ relative to the given artist.
+ '''
if isinstance(self._artist, Artist):
bbox = self._artist.get_window_extent(renderer)
l, b, w, h = bbox.bounds
@@ -1920,16 +1962,6 @@ def draggable(self, state=None, use_blit=False):
class Annotation(Text, _AnnotationBase):
- """
- A :class:`~matplotlib.text.Text` class to make annotating things
- in the figure, such as :class:`~matplotlib.figure.Figure`,
- :class:`~matplotlib.axes.Axes`,
- :class:`~matplotlib.patches.Rectangle`, etc., easier.
-
- Annotate the *x*, *y* point *xy* with text *s* at *x*, *y*
- location *xytext*. (If *xytext* = *None*, defaults to *xy*,
- and if *textcoords* = *None*, defaults to *xycoords*).
- """
def __str__(self):
return "Annotation(%g,%g,%s)" % (self.xy[0],
self.xy[1],
@@ -1943,102 +1975,154 @@ def __init__(self, s, xy,
arrowprops=None,
annotation_clip=None,
**kwargs):
- """
- *arrowprops*, if not *None*, is a dictionary of line properties
- (see :class:`matplotlib.lines.Line2D`) for the arrow that connects
- annotation to the point.
-
- If the dictionary has a key *arrowstyle*, a
- `~matplotlib.patches.FancyArrowPatch` instance is created with
- the given dictionary and is drawn. Otherwise, a
- `~matplotlib.patches.YAArrow` patch instance is created and
- drawn. Valid keys for `~matplotlib.patches.YAArrow` are:
-
-
- ========= ===========================================================
- Key Description
- ========= ===========================================================
- width the width of the arrow in points
- frac the fraction of the arrow length occupied by the head
- headwidth the width of the base of the arrow head in points
- shrink oftentimes it is convenient to have the arrowtip
- and base a bit away from the text and point being
- annotated. If *d* is the distance between the text and
- annotated point, shrink will shorten the arrow so the tip
- and base are shink percent of the distance *d* away from
- the endpoints. i.e., ``shrink=0.05 is 5%%``
- ? any key for :class:`matplotlib.patches.polygon`
- ========= ===========================================================
-
-
- Valid keys for `~matplotlib.patches.FancyArrowPatch` are:
-
-
- =============== ======================================================
- Key Description
- =============== ======================================================
- arrowstyle the arrow style
- connectionstyle the connection style
- relpos default is (0.5, 0.5)
- patchA default is bounding box of the text
- patchB default is None
- shrinkA default is 2 points
- shrinkB default is 2 points
- mutation_scale default is text size (in points)
- mutation_aspect default is 1.
- ? any key for :class:`matplotlib.patches.PathPatch`
- =============== ======================================================
-
-
- *xycoords* and *textcoords* are strings that indicate the
- coordinates of *xy* and *xytext*, and may be one of the
- following values:
-
- ================= ===================================================
- Property Description
- ================= ===================================================
- 'figure points' points from the lower left corner of the figure
- 'figure pixels' pixels from the lower left corner of the figure
- 'figure fraction' 0,0 is lower left of figure and 1,1 is upper right
- 'axes points' points from lower left corner of axes
- 'axes pixels' pixels from lower left corner of axes
- 'axes fraction' 0,0 is lower left of axes and 1,1 is upper right
- 'data' use the coordinate system of the object being
- annotated (default)
- 'offset points' Specify an offset (in points) from the *xy* value
-
- 'polar' you can specify *theta*, *r* for the annotation,
- even in cartesian plots. Note that if you
- are using a polar axes, you do not need
- to specify polar for the coordinate
- system since that is the native "data" coordinate
- system.
- ================= ===================================================
-
- If a 'points' or 'pixels' option is specified, values will be
- added to the bottom-left and if negative, values will be
- subtracted from the top-right. e.g.::
-
- # 10 points to the right of the left border of the axes and
- # 5 points below the top border
- xy=(10,-5), xycoords='axes points'
-
- You may use an instance of
- :class:`~matplotlib.transforms.Transform` or
- :class:`~matplotlib.artist.Artist`. See
- :ref:`plotting-guide-annotation` for more details.
-
- The *annotation_clip* attribute controls the visibility of the
- annotation when it goes outside the axes area. If `True`, the
- annotation will only be drawn when the *xy* is inside the
- axes. If `False`, the annotation will always be drawn
- regardless of its position. The default is `None`, which
- behave as `True` only if *xycoords* is "data".
-
- Additional kwargs are `~matplotlib.text.Text` properties:
+ '''
+ Annotate the point ``xy`` with text ``s``.
+
+ Additional kwargs are passed to `~matplotlib.text.Text`.
+
+ Parameters
+ ----------
+
+ s : str
+ The text of the annotation
+
+ xy : iterable
+ Length 2 sequence specifying the *(x,y)* point to annotate
+
+ xytext : iterable, optional
+ Length 2 sequence specifying the *(x,y)* to place the text
+ at. If None, defaults to ``xy``.
+
+ xycoords : str, Artist, Transform, callable or tuple, optional
+
+ The coordinate system that ``xy`` is given in.
+
+ For a `str` the allowed values are:
+
+ ================= ===============================================
+ Property Description
+ ================= ===============================================
+ 'figure points' points from the lower left of the figure
+ 'figure pixels' pixels from the lower left of the figure
+ 'figure fraction' fraction of figure from lower left
+ 'axes points' points from lower left corner of axes
+ 'axes pixels' pixels from lower left corner of axes
+ 'axes fraction' fraction of axes from lower left
+ 'data' use the coordinate system of the object being
+ annotated (default)
+ 'polar' *(theta,r)* if not native 'data' coordinates
+ ================= ===============================================
+
+ If a `~matplotlib.artist.Artist` object is passed in the units are
+ fraction if it's bounding box.
+
+ If a `~matplotlib.transforms.Transform` object is passed
+ in use that to transform ``xy`` to screen coordinates
+
+ If a callable it must take a
+ `~matplotlib.backend_bases.RendererBase` object as input
+ and return a `~matplotlib.transforms.Transform` or
+ `~matplotlib.transforms.Bbox` object
+
+ If a `tuple` must be length 2 tuple of str, `Artist`,
+ `Transform` or callable objects. The first transform is
+ used for the *x* coordinate and the second for *y*.
+
+ See :ref:`plotting-guide-annotation` for more details.
+
+ Defaults to ``'data'``
+
+ textcoords : str, `Artist`, `Transform`, callable or tuple, optional
+ The coordinate system that ``xytext`` is given, which
+ may be different than the coordinate system used for
+ ``xy``.
+
+ All ``xycoords`` values are valid as well as the following
+ strings:
+
+ ================= =========================================
+ Property Description
+ ================= =========================================
+ 'offset points' offset (in points) from the *xy* value
+ 'offset pixels' offset (in pixels) from the *xy* value
+ ================= =========================================
+
+ defaults to the input of ``xycoords``
+
+ arrowprops : dict, optional
+ If not None, properties used to draw a
+ `~matplotlib.patches.FancyArrowPatch` arrow between ``xy`` and
+ ``xytext``.
+
+ If `arrowprops` does not contain the key ``'arrowstyle'`` the
+ allowed keys are:
+
+ ========== ======================================================
+ Key Description
+ ========== ======================================================
+ width the width of the arrow in points
+ headwidth the width of the base of the arrow head in points
+ headlength the length of the arrow head in points
+ shrink fraction of total length to 'shrink' from both ends
+ ? any key to :class:`matplotlib.patches.FancyArrowPatch`
+ ========== ======================================================
+
+ If the `arrowprops` contains the key ``'arrowstyle'`` the
+ above keys are forbidden. The allowed values of
+ ``'arrowstyle'`` are:
+
+ ============ =============================================
+ Name Attrs
+ ============ =============================================
+ ``'-'`` None
+ ``'->'`` head_length=0.4,head_width=0.2
+ ``'-['`` widthB=1.0,lengthB=0.2,angleB=None
+ ``'|-|'`` widthA=1.0,widthB=1.0
+ ``'-|>'`` head_length=0.4,head_width=0.2
+ ``'<-'`` head_length=0.4,head_width=0.2
+ ``'<->'`` head_length=0.4,head_width=0.2
+ ``'<|-'`` head_length=0.4,head_width=0.2
+ ``'<|-|>'`` head_length=0.4,head_width=0.2
+ ``'fancy'`` head_length=0.4,head_width=0.4,tail_width=0.4
+ ``'simple'`` head_length=0.5,head_width=0.5,tail_width=0.2
+ ``'wedge'`` tail_width=0.3,shrink_factor=0.5
+ ============ =============================================
+
+ Valid keys for `~matplotlib.patches.FancyArrowPatch` are:
+
+ =============== ==================================================
+ Key Description
+ =============== ==================================================
+ arrowstyle the arrow style
+ connectionstyle the connection style
+ relpos default is (0.5, 0.5)
+ patchA default is bounding box of the text
+ patchB default is None
+ shrinkA default is 2 points
+ shrinkB default is 2 points
+ mutation_scale default is text size (in points)
+ mutation_aspect default is 1.
+ ? any key for :class:`matplotlib.patches.PathPatch`
+ =============== ==================================================
+
+ Defaults to None
+
+ annotation_clip : bool, optional
+ Controls the visibility of the annotation when it goes
+ outside the axes area.
+
+ If `True`, the annotation will only be drawn when the
+ ``xy`` is inside the axes. If `False`, the annotation will
+ always be drawn regardless of its position.
+
+ The default is `None`, which behave as `True` only if
+ *xycoords* is "data".
+
+ Returns
+ -------
+ Annotation
- %(Text)s
- """
+ '''
_AnnotationBase.__init__(self,
xy,
@@ -2159,7 +2243,7 @@ def _update_position_xytext(self, renderer, xy_pixel):
frac = d.pop('frac', None)
if frac is not None:
warnings.warn(
- "'frac' option in 'arrowstyle' is no longer supported;"
+ "'frac' option in 'arrowprops' is no longer supported;"
" use 'headlength' to set the head length in points.")
headlength = d.pop('headlength', 12)
diff --git a/lib/matplotlib/widgets.py b/lib/matplotlib/widgets.py
index 112494b59359..312cb7ef0f43 100644
--- a/lib/matplotlib/widgets.py
+++ b/lib/matplotlib/widgets.py
@@ -1381,7 +1381,7 @@ class SpanSelector(_SelectorWidget):
ax.plot(x,y)
def onselect(vmin, vmax):
- print vmin, vmax
+ print(vmin, vmax)
span = SpanSelector(ax, onselect, 'horizontal')
*onmove_callback* is an optional callback that is called on mouse
@@ -2152,7 +2152,7 @@ class LassoSelector(_SelectorWidget):
ax.plot(x,y)
def onselect(verts):
- print verts
+ print(verts)
lasso = LassoSelector(ax, onselect)
*button* is a list of integers indicating which mouse buttons should