Skip to content

Commit 013c60e

Browse files
committed
Updated DataFrame.plot documentation and visualization guide for backend-specific arguments
1 parent bc24e84 commit 013c60e

File tree

2 files changed

+69
-0
lines changed

2 files changed

+69
-0
lines changed

doc/source/user_guide/visualization.rst

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1806,3 +1806,70 @@ on `the ecosystem page <https://pandas.pydata.org/community/ecosystem.html>`_.
18061806

18071807
Developers guide can be found at
18081808
https://pandas.pydata.org/docs/dev/development/extending.html#plotting-backends
1809+
1810+
Backend-Specific Plotting Arguments
1811+
------------------------------------
1812+
1813+
Pandas provides a consistent ``plot`` API, but the availability and implementation of
1814+
optional arguments vary across different backends.
1815+
1816+
The following table outlines commonly used optional arguments and their alternatives
1817+
across different backends.
1818+
1819+
+-------------+------------------------------------+---------------------------------+
1820+
| Matplotlib | Plotly | Bokeh |
1821+
+=============+====================================+=================================+
1822+
| `color` | `line.color` | `line_color` |
1823+
+-------------+------------------------------------+---------------------------------+
1824+
| `figsize` | `fig.update_layout(width, height)` | `plot_width`, `plot_height` |
1825+
+-------------+------------------------------------+---------------------------------+
1826+
| `linewidth` | `line_width` | `line_width` |
1827+
+-------------+------------------------------------+---------------------------------+
1828+
| `linestyle` | `dash` | `line_dash` |
1829+
+-------------+------------------------------------+---------------------------------+
1830+
| `marker` | `marker_symbol` | Use Marker glyph (e.g., circle) |
1831+
+-------------+------------------------------------+---------------------------------+
1832+
| `alpha` | `opacity` | `line_alpha`, `fill_alpha` |
1833+
+-------------+------------------------------------+---------------------------------+
1834+
| `legend` | `showlegend` | `legend_location` |
1835+
+-------------+------------------------------------+---------------------------------+
1836+
1837+
**Example Usage:**
1838+
1839+
- **Matplotlib** (default backend)
1840+
1841+
.. code-block:: python
1842+
1843+
>>> df.plot(
1844+
>>> kind="line", color="red", figsize=(8, 5), linewidth=2, linestyle="--",
1845+
>>> marker="o", alpha=0.7, legend=True
1846+
>>> )
1847+
1848+
- **Plotly**
1849+
1850+
.. code-block:: python
1851+
1852+
>>> pd.options.plotting.backend = "plotly"
1853+
>>> fig = df.plot(
1854+
>>> color="red", line_width=2, dash="dash", marker_symbol="circle",
1855+
>>> opacity=0.7, showlegend=True
1856+
>>> )
1857+
>>> fig.update_layout(width=800, height=500)
1858+
>>> fig.show()
1859+
1860+
- **Bokeh**
1861+
1862+
.. code-block:: python
1863+
1864+
>>> pd.options.plotting.backend = "bokeh"
1865+
>>> df.plot(
1866+
>>> line_color="red", plot_width=800, plot_height=500, line_width=2,
1867+
>>> line_dash="dashed", marker="circle", line_alpha=0.7,
1868+
>>> legend_location="top_right"
1869+
>>> )
1870+
1871+
For more details, refer to:
1872+
1873+
* `Matplotlib Documentation <https://matplotlib.org/stable/contents.html>`_
1874+
* `Plotly Documentation <https://plotly.com/python/>`_
1875+
* `Bokeh Documentation <https://docs.bokeh.org/en/latest/>`_

pandas/plotting/_core.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -827,6 +827,8 @@ class PlotAccessor(PandasObject):
827827
Notes
828828
-----
829829
- See matplotlib documentation online for more on this subject
830+
- For more information on plotting backends, see the `documentation here
831+
<https://pandas.pydata.org/pandas-docs/dev/user_guide/visualization.html#plotting-backends>`_.
830832
- If `kind` = 'bar' or 'barh', you can specify relative alignments
831833
for bar plot layout by `position` keyword.
832834
From 0 (left/bottom-end) to 1 (right/top-end). Default is 0.5

0 commit comments

Comments
 (0)