1.4.5.3 代码文档

代码都有很好的文档,你可以在Python会话中用特定命令很快的访问:

In [3]:

  1. import pylab as pl
  2. help(pl.plot)
  1. Help on function plot in module matplotlib.pyplot:
  2. plot(*args, **kwargs)
  3. Plot lines and/or markers to the
  4. :class:`~matplotlib.axes.Axes`. *args* is a variable length
  5. argument, allowing for multiple *x*, *y* pairs with an
  6. optional format string. For example, each of the following is
  7. legal::
  8. plot(x, y) # plot x and y using default line style and color
  9. plot(x, y, 'bo') # plot x and y using blue circle markers
  10. plot(y) # plot y using x as index array 0..N-1
  11. plot(y, 'r+') # ditto, but with red plusses
  12. If *x* and/or *y* is 2-dimensional, then the corresponding columns
  13. will be plotted.
  14. An arbitrary number of *x*, *y*, *fmt* groups can be
  15. specified, as in::
  16. a.plot(x1, y1, 'g^', x2, y2, 'g-')
  17. Return value is a list of lines that were added.
  18. By default, each line is assigned a different color specified by a
  19. 'color cycle'. To change this behavior, you can edit the
  20. axes.color_cycle rcParam.
  21. The following format string characters are accepted to control
  22. the line style or marker:
  23. ================ ===============================
  24. character description
  25. ================ ===============================
  26. ``'-'`` solid line style
  27. ``'--'`` dashed line style
  28. ``'-.'`` dash-dot line style
  29. ``':'`` dotted line style
  30. ``'.'`` point marker
  31. ``','`` pixel marker
  32. ``'o'`` circle marker
  33. ``'v'`` triangle_down marker
  34. ``'^'`` triangle_up marker
  35. ``'<'`` triangle_left marker
  36. ``'>'`` triangle_right marker
  37. ``'1'`` tri_down marker
  38. ``'2'`` tri_up marker
  39. ``'3'`` tri_left marker
  40. ``'4'`` tri_right marker
  41. ``'s'`` square marker
  42. ``'p'`` pentagon marker
  43. ``'*'`` star marker
  44. ``'h'`` hexagon1 marker
  45. ``'H'`` hexagon2 marker
  46. ``'+'`` plus marker
  47. ``'x'`` x marker
  48. ``'D'`` diamond marker
  49. ``'d'`` thin_diamond marker
  50. ``'|'`` vline marker
  51. ``'_'`` hline marker
  52. ================ ===============================
  53. The following color abbreviations are supported:
  54. ========== ========
  55. character color
  56. ========== ========
  57. 'b' blue
  58. 'g' green
  59. 'r' red
  60. 'c' cyan
  61. 'm' magenta
  62. 'y' yellow
  63. 'k' black
  64. 'w' white
  65. ========== ========
  66. In addition, you can specify colors in many weird and
  67. wonderful ways, including full names (``'green'``), hex
  68. strings (``'#008000'``), RGB or RGBA tuples (``(0,1,0,1)``) or
  69. grayscale intensities as a string (``'0.8'``). Of these, the
  70. string specifications can be used in place of a ``fmt`` group,
  71. but the tuple forms can be used only as ``kwargs``.
  72. Line styles and colors are combined in a single format string, as in
  73. ``'bo'`` for blue circles.
  74. The *kwargs* can be used to set line properties (any property that has
  75. a ``set_*`` method). You can use this to set a line label (for auto
  76. legends), linewidth, anitialising, marker face color, etc. Here is an
  77. example::
  78. plot([1,2,3], [1,2,3], 'go-', label='line 1', linewidth=2)
  79. plot([1,2,3], [1,4,9], 'rs', label='line 2')
  80. axis([0, 4, 0, 10])
  81. legend()
  82. If you make multiple lines with one plot command, the kwargs
  83. apply to all those lines, e.g.::
  84. plot(x1, y1, x2, y2, antialised=False)
  85. Neither line will be antialiased.
  86. You do not need to use format strings, which are just
  87. abbreviations. All of the line properties can be controlled
  88. by keyword arguments. For example, you can set the color,
  89. marker, linestyle, and markercolor with::
  90. plot(x, y, color='green', linestyle='dashed', marker='o',
  91. markerfacecolor='blue', markersize=12).
  92. See :class:`~matplotlib.lines.Line2D` for details.
  93. The kwargs are :class:`~matplotlib.lines.Line2D` properties:
  94. agg_filter: unknown
  95. alpha: float (0.0 transparent through 1.0 opaque)
  96. animated: [True | False]
  97. antialiased or aa: [True | False]
  98. axes: an :class:`~matplotlib.axes.Axes` instance
  99. clip_box: a :class:`matplotlib.transforms.Bbox` instance
  100. clip_on: [True | False]
  101. clip_path: [ (:class:`~matplotlib.path.Path`, :class:`~matplotlib.transforms.Transform`) | :class:`~matplotlib.patches.Patch` | None ]
  102. color or c: any matplotlib color
  103. contains: a callable function
  104. dash_capstyle: ['butt' | 'round' | 'projecting']
  105. dash_joinstyle: ['miter' | 'round' | 'bevel']
  106. dashes: sequence of on/off ink in points
  107. drawstyle: ['default' | 'steps' | 'steps-pre' | 'steps-mid' | 'steps-post']
  108. figure: a :class:`matplotlib.figure.Figure` instance
  109. fillstyle: ['full' | 'left' | 'right' | 'bottom' | 'top' | 'none']
  110. gid: an id string
  111. label: string or anything printable with '%s' conversion.
  112. linestyle or ls: [``'-'`` | ``'--'`` | ``'-.'`` | ``':'`` | ``'None'`` | ``' '`` | ``''``]
  113. linewidth or lw: float value in points
  114. lod: [True | False]
  115. marker: unknown
  116. markeredgecolor or mec: any matplotlib color
  117. markeredgewidth or mew: float value in points
  118. markerfacecolor or mfc: any matplotlib color
  119. markerfacecoloralt or mfcalt: any matplotlib color
  120. markersize or ms: float
  121. markevery: unknown
  122. path_effects: unknown
  123. picker: float distance in points or callable pick function ``fn(artist, event)``
  124. pickradius: float distance in points
  125. rasterized: [True | False | None]
  126. sketch_params: unknown
  127. snap: unknown
  128. solid_capstyle: ['butt' | 'round' | 'projecting']
  129. solid_joinstyle: ['miter' | 'round' | 'bevel']
  130. transform: a :class:`matplotlib.transforms.Transform` instance
  131. url: a url string
  132. visible: [True | False]
  133. xdata: 1D array
  134. ydata: 1D array
  135. zorder: any number
  136. kwargs *scalex* and *scaley*, if defined, are passed on to
  137. :meth:`~matplotlib.axes.Axes.autoscale_view` to determine
  138. whether the *x* and *y* axes are autoscaled; the default is
  139. *True*.
  140. Additional kwargs: hold = [True|False] overrides default hold state