Skip to content

Commit 67209ee

Browse files
authored
DOC: Fixing EX01 - Added examples (#54217)
* Examples plotting.table & plot_params * Remove error on CI * less data for plot_parms * correcting table * fix plot_params error on CI
1 parent 3c01ce2 commit 67209ee

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

ci/code_checks.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,7 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
7979
pandas.io.stata.StataReader.variable_labels \
8080
pandas.io.stata.StataWriter.write_file \
8181
pandas.plotting.deregister_matplotlib_converters \
82-
pandas.plotting.plot_params \
8382
pandas.plotting.register_matplotlib_converters \
84-
pandas.plotting.table \
8583
pandas.util.hash_array \
8684
pandas.util.hash_pandas_object \
8785
pandas_object \

pandas/plotting/_misc.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,20 @@ def table(ax: Axes, data: DataFrame | Series, **kwargs) -> Table:
4343
Returns
4444
-------
4545
matplotlib table object
46+
47+
Examples
48+
--------
49+
50+
.. plot::
51+
:context: close-figs
52+
53+
>>> import matplotlib.pyplot as plt
54+
>>> df = pd.DataFrame({'A': [1, 2], 'B': [3, 4]})
55+
>>> fix, ax = plt.subplots()
56+
>>> ax.axis('off')
57+
(0.0, 1.0, 0.0, 1.0)
58+
>>> table = pd.plotting.table(ax, df, loc='center',
59+
... cellLoc='center', colWidths=list([.2, .2]))
4660
"""
4761
plot_backend = _get_plot_backend("matplotlib")
4862
return plot_backend.table(
@@ -552,6 +566,21 @@ class _Options(dict):
552566
Allows for parameter aliasing so you can just use parameter names that are
553567
the same as the plot function parameters, but is stored in a canonical
554568
format that makes it easy to breakdown into groups later.
569+
570+
Examples
571+
--------
572+
573+
.. plot::
574+
:context: close-figs
575+
576+
>>> np.random.seed(42)
577+
>>> df = pd.DataFrame({'A': np.random.randn(10),
578+
... 'B': np.random.randn(10)},
579+
... index=pd.date_range("1/1/2000",
580+
... freq='4MS', periods=10))
581+
>>> with pd.plotting.plot_params.use("x_compat", True):
582+
... _ = df["A"].plot(color="r")
583+
... _ = df["B"].plot(color="g")
555584
"""
556585

557586
# alias so the names are same as plotting method parameter names

0 commit comments

Comments
 (0)