python matplotlib.figure.Figure.add_subplot()方法的使用
生活随笔
收集整理的這篇文章主要介紹了
python matplotlib.figure.Figure.add_subplot()方法的使用
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
官方文檔
https://matplotlib.org/api/_as_gen/matplotlib.figure.Figure.html?highlight=add_subplot#matplotlib.figure.Figure.add_subplot
本地doc:
Signature: figure.add_subplot(*args, **kwargs) Docstring: Add an `~.axes.Axes` to the figure as part of a subplot arrangement. 作為子圖布置的一部分,在圖中添加一個?.axes.Axes。Call signatures::add_subplot(nrows, ncols, index, **kwargs)add_subplot(pos, **kwargs)add_subplot(ax)add_subplot()Parameters ---------- *argsEither a 3-digit integer or three separate integersdescribing the position of the subplot. If the threeintegers are *nrows*, *ncols*, and *index* in order, thesubplot will take the *index* position on a grid with *nrows*rows and *ncols* columns. *index* starts at 1 in the upper leftcorner and increases to the right.*pos* is a three digit integer, where the first digit is thenumber of rows, the second the number of columns, and the thirdthe index of the subplot. i.e. fig.add_subplot(235) is the same asfig.add_subplot(2, 3, 5). Note that all integers must be less than10 for this form to work.If no positional arguments are passed, defaults to (1, 1, 1).In rare circumstances, `.add_subplot` may be called with a singleargument, a subplot axes instance already created in thepresent figure but not in the figure's list of axes.projection : {None, 'aitoff', 'hammer', 'lambert', 'mollweide', 'polar', 'rectilinear', str}, optionalThe projection type of the subplot (`~.axes.Axes`). *str* is thename of a custom projection, see `~matplotlib.projections`. Thedefault None results in a 'rectilinear' projection.polar : boolean, optionalIf True, equivalent to projection='polar'.sharex, sharey : `~.axes.Axes`, optionalShare the x or y `~matplotlib.axis` with sharex and/or sharey.The axis will have the same limits, ticks, and scale as the axisof the shared axes.label : strA label for the returned axes.Other Parameters ---------------- **kwargsThis method also takes the keyword arguments forthe returned axes base class. The keyword arguments for therectilinear base class `~.axes.Axes` can be found inthe following table but there might also be other keywordarguments if another projection is used.adjustable: {'box', 'datalim'}agg_filter: a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) arrayalpha: floatanchor: 2-tuple of floats or {'C', 'SW', 'S', 'SE', ...}animated: boolaspect: {'auto', 'equal'} or numautoscale_on: boolautoscalex_on: boolautoscaley_on: boolaxes_locator: Callable[[Axes, Renderer], Bbox]axisbelow: bool or 'line'clip_box: `.Bbox`clip_on: boolclip_path: [(`~matplotlib.path.Path`, `.Transform`) | `.Patch` | None]contains: callablefacecolor: colorfc: colorfigure: `.Figure`frame_on: boolgid: strin_layout: boollabel: objectnavigate: boolnavigate_mode: unknownpath_effects: `.AbstractPathEffect`picker: None or bool or float or callableposition: [left, bottom, width, height] or `~matplotlib.transforms.Bbox`rasterization_zorder: float or Nonerasterized: bool or Nonesketch_params: (scale: float, length: float, randomness: float)snap: bool or Nonetitle: strtransform: `.Transform`url: strvisible: boolxbound: unknownxlabel: strxlim: (left: float, right: float)xmargin: float greater than -0.5xscale: {"linear", "log", "symlog", "logit", ...}xticklabels: List[str]xticks: listybound: unknownylabel: strylim: (bottom: float, top: float)ymargin: float greater than -0.5yscale: {"linear", "log", "symlog", "logit", ...}yticklabels: List[str]yticks: listzorder: floatReturns ------- axes : `.axes.SubplotBase`, or another subclass of `~.axes.Axes`The axes of the subplot. The returned axes base class depends onthe projection used. It is `~.axes.Axes` if rectilinear projectionare used and `.projections.polar.PolarAxes` if polar projectionare used. The returned axes is then a subplot subclass of thebase class.Notes ----- If the figure already has a subplot with key (*args*, *kwargs*) then it will simply make that subplot current and return it. This behavior is deprecated. Meanwhile, if you do not want this behavior (i.e., you want to force the creation of a new subplot), you must use a unique set of args and kwargs. The axes *label* attribute has been exposed for this purpose: if you want two subplots that are otherwise identical to be added to the figure, make sure you give them unique labels.See Also -------- .Figure.add_axes .pyplot.subplot .pyplot.axes .Figure.subplots .pyplot.subplotsExamples -------- ::fig = plt.figure()fig.add_subplot(221)# equivalent but more generalax1 = fig.add_subplot(2, 2, 1)# add a subplot with no frameax2 = fig.add_subplot(222, frameon=False)# add a polar subplotfig.add_subplot(223, projection='polar')# add a red subplot that share the x-axis with ax1fig.add_subplot(224, sharex=ax1, facecolor='red')#delete x2 from the figurefig.delaxes(ax2)#add x2 to the figure againfig.add_subplot(ax2) File: c:\users\huawei\appdata\local\programs\python\python36\lib\site-packages\matplotlib\figure.py Type: method總結
以上是生活随笔為你收集整理的python matplotlib.figure.Figure.add_subplot()方法的使用的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python mpl_toolkits.
- 下一篇: python 理解Matplotlib