Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doc for backend-specific arguments for df.plot() #61078

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions doc/source/user_guide/visualization.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1806,3 +1806,70 @@ on `the ecosystem page <https://pandas.pydata.org/community/ecosystem.html>`_.

Developers guide can be found at
https://pandas.pydata.org/docs/dev/development/extending.html#plotting-backends

Backend-Specific Plotting Arguments
------------------------------------

Pandas provides a consistent ``plot`` API, but the availability and implementation of
optional arguments vary across different backends.

The following table outlines commonly used optional arguments and their alternatives
across different backends.

+-------------+------------------------------------+---------------------------------+
| Matplotlib | Plotly | Bokeh |
+=============+====================================+=================================+
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you link to specific documentation page of Plotly and Bokeh instead (like https://plotly.com/python/pandas-backend/)? This will be hard to maintain if their APIs ever change

| `color` | `line.color` | `line_color` |
+-------------+------------------------------------+---------------------------------+
| `figsize` | `fig.update_layout(width, height)` | `plot_width`, `plot_height` |
+-------------+------------------------------------+---------------------------------+
| `linewidth` | `line_width` | `line_width` |
+-------------+------------------------------------+---------------------------------+
| `linestyle` | `dash` | `line_dash` |
+-------------+------------------------------------+---------------------------------+
| `marker` | `marker_symbol` | Use Marker glyph (e.g., circle) |
+-------------+------------------------------------+---------------------------------+
| `alpha` | `opacity` | `line_alpha`, `fill_alpha` |
+-------------+------------------------------------+---------------------------------+
| `legend` | `showlegend` | `legend_location` |
+-------------+------------------------------------+---------------------------------+

**Example Usage:**

- **Matplotlib** (default backend)

.. code-block:: python

>>> df.plot(
>>> kind="line", color="red", figsize=(8, 5), linewidth=2, linestyle="--",
>>> marker="o", alpha=0.7, legend=True
>>> )

- **Plotly**

.. code-block:: python

>>> pd.options.plotting.backend = "plotly"
>>> fig = df.plot(
>>> color="red", line_width=2, dash="dash", marker_symbol="circle",
>>> opacity=0.7, showlegend=True
>>> )
>>> fig.update_layout(width=800, height=500)
>>> fig.show()

- **Bokeh**

.. code-block:: python

>>> pd.options.plotting.backend = "bokeh"
>>> df.plot(
>>> line_color="red", plot_width=800, plot_height=500, line_width=2,
>>> line_dash="dashed", marker="circle", line_alpha=0.7,
>>> legend_location="top_right"
>>> )

For more details, refer to:

* `Matplotlib Documentation <https://matplotlib.org/stable/contents.html>`_
* `Plotly Documentation <https://plotly.com/python/>`_
* `Bokeh Documentation <https://docs.bokeh.org/en/latest/>`_
2 changes: 2 additions & 0 deletions pandas/plotting/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -827,6 +827,8 @@ class PlotAccessor(PandasObject):
Notes
-----
- See matplotlib documentation online for more on this subject
- For more information on plotting backends, see the `documentation here
<https://pandas.pydata.org/pandas-docs/dev/user_guide/visualization.html#plotting-backends>`_.
- If `kind` = 'bar' or 'barh', you can specify relative alignments
for bar plot layout by `position` keyword.
From 0 (left/bottom-end) to 1 (right/top-end). Default is 0.5
Expand Down
Loading