Thanks to visit codestin.com
Credit goes to github.com

Skip to content

DOC: keyword arguments to plt.axes, plt.subpot, and fig.add_subplotΒ #1461

Closed
@ivanov

Description

@ivanov

having a bit of a fun bug chain here, this time, while filling out πŸƒπŸ’¨#1460, I noticed some inconsistencies in our docs:

in our docs, plt.axes takes these kwargs:

axisbg    color          the axes background color
frameon   [True|False]   display the frame?
sharex    otherax        current axes shares xaxis attribute with otherax
sharey    otherax        current axes shares yaxis attribute with otherax
polar     [True|False]   use a polar axes?

and plt.subplot says it deals with axisbg, polar, and projection.

but it turns out that both also seems to accept a whole bunch of others, since plt.subplot(111, xlim=(0, 3.1415)) works just fine.

Here are all of the kwargs listed for fig.add_subplot:

  adjustable: [ 'box' | 'datalim' | 'box-forced']         
  agg_filter: unknown
  alpha: float (0.0 transparent through 1.0 opaque)         
  anchor: unknown
  animated: [True | False]         
  aspect: unknown
  autoscale_on: unknown
  autoscalex_on: unknown
  autoscaley_on: unknown
  axes: an :class:`~matplotlib.axes.Axes` instance         
  axes_locator: unknown
  axis_bgcolor: any matplotlib color - see         :func:`~matplotlib.pyplot.colors`         
  axis_off: unknown
  axis_on: unknown
  axisbelow: [ *True* | *False* ]         
  clip_box: a :class:`matplotlib.transforms.Bbox` instance         
  clip_on: [True | False]         
  clip_path: [ (:class:`~matplotlib.path.Path`,         :class:`~matplotlib.transforms.Transform`) |         :class:`~matplotlib.patches.Patch` | None ]         
  color_cycle: unknown
  contains: a callable function         
  cursor_props: a (*float*, *color*) tuple         
  figure: unknown
  frame_on: [ *True* | *False* ]         
  gid: an id string         
  label: string or anything printable with '%s' conversion.         
  lod: [True | False]         
  navigate: [ *True* | *False* ]         
  navigate_mode: unknown
  picker: [None|float|boolean|callable]         
  position: unknown
  rasterization_zorder: unknown
  rasterized: [True | False | None]         
  snap: unknown
  title: str
  transform: :class:`~matplotlib.transforms.Transform` instance         
  url: a url string         
  visible: [True | False]         
  xbound: unknown
  xlabel: str
  xlim: length 2 sequence of floats         
  xmargin: unknown
  xscale: ['linear' | 'log' | 'symlog']
  xticklabels: sequence of strings
  xticks: sequence of floats         
  ybound: unknown
  ylabel: str
  ylim: length 2 sequence of floats         
  ymargin: unknown
  yscale: ['linear' | 'log' | 'symlog']
  yticklabels: sequence of strings
  yticks: sequence of floats
  zorder: any number

I have not verified, but suspect all of the above work as kwargs to plt.subplot and plt.axes. If that is indeed the case, we should add this information to both plt.subplot and plt.axes.

As far as the implementation of that in the code is concerned, this would simply entail adding @docstring.dedent_interpd decorator to the methods involved, and having something like:

"""
The following kwargs are supported:

%(Axes)s
"""

in the docstring for those methods, which will insert all of those keyword argument descriptions. See the add_subplot method in matplotlib/figure.py or just plt.Figure.add_subplot?? in IPython

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions