Skip to content

Commit 822f528

Browse files
author
Phil Elson
committed
Squashed commit of the following:
commit 597b6f0 Author: Phil Elson <philipelson@hotmail.com> Date: Fri Mar 16 16:35:01 2012 +0000 Changed version which these changes take effect. commit 270f291 Author: Phil Elson <philipelson@hotmail.com> Date: Wed Feb 29 13:22:03 2012 +0000 Review actions #3 commit 564e042 Author: Phil Elson <philipelson@hotmail.com> Date: Mon Feb 27 17:18:46 2012 +0000 Review actions #2 commit 836a459 Author: Phil Elson <philipelson@hotmail.com> Date: Mon Feb 20 15:40:06 2012 +0000 Fixed error raising unittest case commit 677a0ed Author: Phil Elson <philipelson@hotmail.com> Date: Mon Feb 20 13:44:07 2012 +0000 Minor doc changes commit f8021a2 Author: Phil Elson <philipelson@hotmail.com> Date: Mon Feb 20 13:36:11 2012 +0000 Review actions commit 7674dcd Author: Phil Elson <philipelson@hotmail.com> Date: Mon Feb 6 18:14:24 2012 +0000 Further tweaks re add_axes. commit 89053c5 Author: Phil Elson <philipelson@hotmail.com> Date: Mon Feb 6 18:03:49 2012 +0000 Reverted polar check. commit 1fa7d39 Author: Phil Elson <philipelson@hotmail.com> Date: Mon Feb 6 17:56:09 2012 +0000 Corrected having not hit git add before committing. commit eb37499 Author: Phil Elson <philipelson@hotmail.com> Date: Mon Feb 6 17:53:51 2012 +0000 Fixed error messages substitution. commit bd0fd6e Author: Phil Elson <philipelson@hotmail.com> Date: Mon Feb 6 16:56:34 2012 +0000 Matching up diffs with github's diff viewer (newlines). commit 53cbea6 Author: Phil Elson <philipelson@hotmail.com> Date: Mon Feb 6 16:55:25 2012 +0000 Tidied up branch a little. commit 40a0ec9 Author: Phil Elson <philipelson@hotmail.com> Date: Mon Feb 6 16:51:33 2012 +0000 reverted projections change. commit 756dd8c Author: Phil Elson <philipelson@hotmail.com> Date: Mon Feb 6 16:48:42 2012 +0000 Added documentation, supported add_axes regarding _as_mpl_axes. commit ab0615c Author: Phil Elson <philipelson@hotmail.com> Date: Tue Jan 31 16:57:50 2012 +0000 Tweaked. commit 1a0021b Author: Phil Elson <philipelson@hotmail.com> Date: Tue Jan 31 16:08:58 2012 +0000 Class projection support added.
1 parent 80d1a7c commit 822f528

6 files changed

Lines changed: 211 additions & 92 deletions

File tree

‎doc/api/api_changes.rst‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,20 @@ help figure out possible sources of the changes you are experiencing.
1111
For new features that were added to matplotlib, please see
1212
:ref:`whats-new`.
1313

14+
Changes in 1.2.x
15+
================
16+
* Use of :func:`matplotlib.projections.projection_factory` is now deprecated
17+
in favour of axes class identification using
18+
:func:`matplotlib.projections.process_projection_requirements` followed by
19+
direct axes class invocation (at the time of writing, this is done by
20+
:meth:`matplotlib.figure.Figure.add_axes`,
21+
:meth:`matplotlib.figure.Figure.add_subplot` and
22+
:meth:`matplotlib.figure.Figure.gca`.
23+
This change means that third party objects can expose themselves as
24+
matplotlib axes by providing a ``_as_mpl_axes`` method (see
25+
:ref:`adding-new-scales` for more detail).
26+
27+
1428
Changes in 1.1.x
1529
================
1630

‎doc/devel/add_new_projection.rst‎

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,9 @@ in :mod:`matplotlib.scale` that may be used as starting points.
7171
Creating a new projection
7272
=========================
7373

74-
Adding a new projection consists of defining a subclass of
75-
:class:`matplotlib.axes.Axes`, that includes the following elements:
74+
Adding a new projection consists of defining a projection axes which
75+
subclasses :class:`matplotlib.axes.Axes` and includes the following
76+
elements:
7677

7778
- A transformation from data coordinates into display coordinates.
7879

@@ -98,11 +99,28 @@ Adding a new projection consists of defining a subclass of
9899
- Set up interactive panning and zooming. This is left as an
99100
"advanced" feature left to the reader, but there is an example of
100101
this for polar plots in :mod:`matplotlib.projections.polar`.
101-
102+
102103
- Any additional methods for additional convenience or features.
103104

104-
Once the class is defined, it must be registered with matplotlib
105-
so that the user can select it.
105+
Once the projection axes is defined, it can be used in one of two ways:
106+
107+
- By defining the class attribute ``NAME``, the projection axes can be
108+
registered with :func:`matplotlib.projections.register_projection`
109+
and subsequently simply invoked by name::
110+
111+
plt.axes(projection=NAME)
112+
113+
- For more complex, parameterisable projections, a generic "projection"
114+
object may be defined which includes the method ``_as_mpl_axes``.
115+
``_as_mpl_axes`` should take no arguments and return the projection's
116+
axes subclass and a dictionary of additional arguments to pass to the
117+
subclass' ``__init__`` method. Subsequently a parameterised projection
118+
can be initialised with::
119+
120+
plt.axes(projection=MyProjection(param1=param1_value))
121+
122+
where MyProjection is an object which implements a ``_as_mpl_axes`` method.
123+
106124

107125
A full-fledged and heavily annotated example is in
108126
:file:`examples/api/custom_projection_example.py`. The polar plot

‎lib/matplotlib/axes.py‎

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -954,15 +954,11 @@ def hold(self, b=None):
954954
Set the hold state. If *hold* is *None* (default), toggle the
955955
*hold* state. Else set the *hold* state to boolean value *b*.
956956
957-
Examples:
958-
959-
* toggle hold:
960-
>>> hold()
961-
* turn hold on:
962-
>>> hold(True)
963-
* turn hold off
964-
>>> hold(False)
965-
957+
Examples::
958+
959+
hold() # toggle hold
960+
hold(True) # turn hold on
961+
hold(False) # turn hold off
966962
967963
When hold is True, subsequent plot commands will be added to
968964
the current axes. When hold is False, the current axes and
@@ -3483,12 +3479,11 @@ def axhspan(self, ymin, ymax, xmin=0, xmax=1, **kwargs):
34833479
Return value is a :class:`matplotlib.patches.Polygon`
34843480
instance.
34853481
3486-
Examples:
3487-
3488-
* draw a gray rectangle from *y* = 0.25-0.75 that spans the
3489-
horizontal extent of the axes
3482+
Examples::
34903483
3491-
>>> axhspan(0.25, 0.75, facecolor='0.5', alpha=0.5)
3484+
# draw a gray rectangle from *y* = 0.25-0.75 that spans the
3485+
# horizontal extent of the axes
3486+
axhspan(0.25, 0.75, facecolor='0.5', alpha=0.5)
34923487
34933488
Valid kwargs are :class:`~matplotlib.patches.Polygon` properties:
34943489
@@ -3539,12 +3534,11 @@ def axvspan(self, xmin, xmax, ymin=0, ymax=1, **kwargs):
35393534
Return value is the :class:`matplotlib.patches.Polygon`
35403535
instance.
35413536
3542-
Examples:
3543-
3544-
* draw a vertical green translucent rectangle from x=1.25 to 1.55 that
3545-
spans the yrange of the axes
3537+
Examples::
35463538
3547-
>>> axvspan(1.25, 1.55, facecolor='g', alpha=0.5)
3539+
# draw a vertical green translucent rectangle from x=1.25 to 1.55
3540+
# that spans the yrange of the axes
3541+
axvspan(1.25, 1.55, facecolor='g', alpha=0.5)
35483542
35493543
Valid kwargs are :class:`~matplotlib.patches.Polygon`
35503544
properties:
@@ -6927,7 +6921,7 @@ def pcolor(self, *args, **kwargs):
69276921
y = np.arange(3)
69286922
X, Y = meshgrid(x,y)
69296923
6930-
is equivalent to:
6924+
is equivalent to::
69316925
69326926
X = array([[0, 1, 2, 3, 4],
69336927
[0, 1, 2, 3, 4],
@@ -7467,11 +7461,11 @@ def hist(self, x, bins=10, range=None, normed=False, weights=None,
74677461
"""
74687462
call signature::
74697463
7470-
def hist(x, bins=10, range=None, normed=False, weights=None,
7464+
hist(x, bins=10, range=None, normed=False, weights=None,
74717465
cumulative=False, bottom=None, histtype='bar', align='mid',
74727466
orientation='vertical', rwidth=None, log=False,
74737467
color=None, label=None,
7474-
**kwargs):
7468+
**kwargs)
74757469
74767470
Compute and draw the histogram of *x*. The return value is a
74777471
tuple (*n*, *bins*, *patches*) or ([*n0*, *n1*, ...], *bins*,

0 commit comments

Comments
 (0)