@@ -865,60 +865,74 @@ def over(func, *args, **kwargs):
865865## Axes ##
866866
867867
868- def axes (* args , ** kwargs ):
868+ def axes (arg = None , ** kwargs ):
869869 """
870- Add an axes to the figure.
870+ Add an axes to the current figure and make it the current axes .
871871
872- The axes is added at position *rect* specified by:
873-
874- - ``axes()`` by itself creates a default full ``subplot(111)`` window axis.
872+ Parameters
873+ ----------
874+ arg : None or 4-tuple or Axes
875+ The exact behavior of this function depends on the type:
876+
877+ - *None*: A new full window axes is added using
878+ ``subplot(111, **kwargs)``
879+ - 4-tuple of floats *rect* = ``[left, bottom, width, height]``.
880+ A new axes is added with dimensions *rect* in normalized
881+ (0, 1) units using `~.Figure.add_axes` on the current figure.
882+ - `~.Axes`: This is equivalent to `.pyplot.sca`. It sets the current
883+ axes to *arg*. Note: This implicitly changes the current figure to
884+ the parent of *arg*.
885+
886+ Other Parameters
887+ ----------------
888+ **kwargs :
889+ For allowed keyword arguments see `.pyplot.subplot` and
890+ `.Figure.add_axes` respectively. Some common keyword arguments are
891+ listed below:
892+
893+ ========= ============== ===========================================
894+ kwarg Accepts Description
895+ ========= ============== ===========================================
896+ facecolor color the axes background color
897+ frameon [True|False] display the frame?
898+ sharex otherax current axes shares xaxis attribute
899+ with otherax
900+ sharey otherax current axes shares yaxis attribute
901+ with otherax
902+ polar [True|False] use a polar axes?
903+ aspect [str | num] ['equal', 'auto'] or a number. If a number
904+ the ratio of y-unit/x-unit in screen-space.
905+ Also see
906+ :meth:`~matplotlib.axes.Axes.set_aspect`.
907+ ========= ============== ===========================================
875908
876- - ``axes(rect, facecolor='w')`` where *rect* = [left, bottom, width,
877- height] in normalized (0, 1) units. *facecolor* is the background
878- color for the axis, default white.
909+ Returns
910+ -------
911+ axes : Axes
912+ The created or activated axes.
879913
880- - ``axes(h)`` where *h* is an axes instance makes *h* the current
881- axis and the parent of *h* the current figure.
882- An :class:`~matplotlib.axes.Axes` instance is returned.
914+ Examples
915+ --------
916+ Creating a new full window axes::
883917
884- ========= ============== ==============================================
885- kwarg Accepts Description
886- ========= ============== ==============================================
887- facecolor color the axes background color
888- frameon [True|False] display the frame?
889- sharex otherax current axes shares xaxis attribute
890- with otherax
891- sharey otherax current axes shares yaxis attribute
892- with otherax
893- polar [True|False] use a polar axes?
894- aspect [str | num] ['equal', 'auto'] or a number. If a number
895- the ratio of x-unit/y-unit in screen-space.
896- Also see
897- :meth:`~matplotlib.axes.Axes.set_aspect`.
898- ========= ============== ==============================================
918+ >>> plt.axes()
899919
900- Examples :
920+ Creating a new axes with specified dimensions and some kwargs: :
901921
902- * :file:`examples/pylab_examples/axes_demo.py` places custom axes.
903- * :file:`examples/pylab_examples/shared_axis_demo.py` uses
904- *sharex* and *sharey*.
922+ >>> plt.axes((left, bottom, width, height), facecolor='w')
905923
906924 """
907925
908- nargs = len (args )
909- if len (args ) == 0 :
926+ if arg is None :
910927 return subplot (111 , ** kwargs )
911- if nargs > 1 :
912- raise TypeError ('Only one non keyword arg to axes allowed' )
913- arg = args [0 ]
914928
915929 if isinstance (arg , Axes ):
916- sca (arg )
917- a = arg
930+ ax = arg
931+ sca (ax )
932+ return ax
918933 else :
919934 rect = arg
920- a = gcf ().add_axes (rect , ** kwargs )
921- return a
935+ return gcf ().add_axes (rect , ** kwargs )
922936
923937
924938def delaxes (ax = None ):
0 commit comments