__init__.py 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. """
  2. Plotting public API.
  3. Authors of third-party plotting backends should implement a module with a
  4. public ``plot(data, kind, **kwargs)``. The parameter `data` will contain
  5. the data structure and can be a `Series` or a `DataFrame`. For example,
  6. for ``df.plot()`` the parameter `data` will contain the DataFrame `df`.
  7. In some cases, the data structure is transformed before being sent to
  8. the backend (see PlotAccessor.__call__ in pandas/plotting/_core.py for
  9. the exact transformations).
  10. The parameter `kind` will be one of:
  11. - line
  12. - bar
  13. - barh
  14. - box
  15. - hist
  16. - kde
  17. - area
  18. - pie
  19. - scatter
  20. - hexbin
  21. See the pandas API reference for documentation on each kind of plot.
  22. Any other keyword argument is currently assumed to be backend specific,
  23. but some parameters may be unified and added to the signature in the
  24. future (e.g. `title` which should be useful for any backend).
  25. Currently, all the Matplotlib functions in pandas are accessed through
  26. the selected backend. For example, `pandas.plotting.boxplot` (equivalent
  27. to `DataFrame.boxplot`) is also accessed in the selected backend. This
  28. is expected to change, and the exact API is under discussion. But with
  29. the current version, backends are expected to implement the next functions:
  30. - plot (describe above, used for `Series.plot` and `DataFrame.plot`)
  31. - hist_series and hist_frame (for `Series.hist` and `DataFrame.hist`)
  32. - boxplot (`pandas.plotting.boxplot(df)` equivalent to `DataFrame.boxplot`)
  33. - boxplot_frame and boxplot_frame_groupby
  34. - register and deregister (register converters for the tick formats)
  35. - Plots not called as `Series` and `DataFrame` methods:
  36. - table
  37. - andrews_curves
  38. - autocorrelation_plot
  39. - bootstrap_plot
  40. - lag_plot
  41. - parallel_coordinates
  42. - radviz
  43. - scatter_matrix
  44. Use the code in pandas/plotting/_matplotib.py and
  45. https://github.com/pyviz/hvplot as a reference on how to write a backend.
  46. For the discussion about the API see
  47. https://github.com/pandas-dev/pandas/issues/26747.
  48. """
  49. from pandas.plotting._core import (
  50. PlotAccessor,
  51. boxplot,
  52. boxplot_frame,
  53. boxplot_frame_groupby,
  54. hist_frame,
  55. hist_series,
  56. )
  57. from pandas.plotting._misc import (
  58. andrews_curves,
  59. autocorrelation_plot,
  60. bootstrap_plot,
  61. deregister as deregister_matplotlib_converters,
  62. lag_plot,
  63. parallel_coordinates,
  64. plot_params,
  65. radviz,
  66. register as register_matplotlib_converters,
  67. scatter_matrix,
  68. table,
  69. )
  70. __all__ = [
  71. "PlotAccessor",
  72. "boxplot",
  73. "boxplot_frame",
  74. "boxplot_frame_groupby",
  75. "hist_frame",
  76. "hist_series",
  77. "scatter_matrix",
  78. "radviz",
  79. "andrews_curves",
  80. "bootstrap_plot",
  81. "parallel_coordinates",
  82. "lag_plot",
  83. "autocorrelation_plot",
  84. "table",
  85. "plot_params",
  86. "register_matplotlib_converters",
  87. "deregister_matplotlib_converters",
  88. ]