From 766bbacf0dd38882a2b43cab6fdc8740c72b1baf Mon Sep 17 00:00:00 2001 From: Rushabh Vasani Date: Thu, 16 Jan 2020 11:06:44 +0530 Subject: [PATCH 1/6] add plotting backends in visualization.rst --- doc/source/user_guide/visualization.rst | 42 +++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/doc/source/user_guide/visualization.rst b/doc/source/user_guide/visualization.rst index 39051440e9d9a..9ae3efd440779 100644 --- a/doc/source/user_guide/visualization.rst +++ b/doc/source/user_guide/visualization.rst @@ -1641,3 +1641,45 @@ when plotting a large number of points. :suppress: plt.close('all') + +Plotting backends +----------------- + +Starting in 0.25 pandas can be extended with third-party plotting backends. The +main idea is letting users select a plotting backend different than the provided +one based on Matplotlib. For example: + +.. code-block:: python + + >>> pd.set_option('plotting.backend', 'backend.module') + >>> pd.Series([1, 2, 3]).plot() + +This would be more or less equivalent to: + +.. code-block:: python + + >>> import backend.module + >>> backend.module.plot(pd.Series([1, 2, 3])) + +The backend module can then use other visualization tools (Bokeh, Altair,...) +to generate the plots. + +Libraries implementing the plotting backend should use `entry points `__ +to make their backend discoverable to pandas. The key is ``"pandas_plotting_backends"``. For example, pandas +registers the default "matplotlib" backend as follows. + +.. code-block:: python + + # in setup.py + setup( # noqa: F821 + ..., + entry_points={ + "pandas_plotting_backends": [ + "matplotlib = pandas:plotting._matplotlib", + ], + }, + ) + + +More information on how to implement a third-party plotting backend can be found at +https://github.com/pandas-dev/pandas/blob/master/pandas/plotting/__init__.py#L1. \ No newline at end of file From 6226d29c21c7ef6354896ccef75dc28db2b140c5 Mon Sep 17 00:00:00 2001 From: Rushabh Vasani Date: Fri, 17 Jan 2020 20:17:11 +0530 Subject: [PATCH 2/6] remove dev guides --- doc/source/user_guide/visualization.rst | 28 ++++++++++--------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/doc/source/user_guide/visualization.rst b/doc/source/user_guide/visualization.rst index 9ae3efd440779..ba14d5a41fd0e 100644 --- a/doc/source/user_guide/visualization.rst +++ b/doc/source/user_guide/visualization.rst @@ -1654,6 +1654,14 @@ one based on Matplotlib. For example: >>> pd.set_option('plotting.backend', 'backend.module') >>> pd.Series([1, 2, 3]).plot() +Same thing can be done by setting the ``pd.options.plotting.backend`` keyword +equals to 'backend.module'. For example: + +.. code-block:: python + + >>> pd.options.plotting.backend = 'backend.module' + >>> pd.Series([1, 2, 3]).plot() + This would be more or less equivalent to: .. code-block:: python @@ -1661,25 +1669,11 @@ This would be more or less equivalent to: >>> import backend.module >>> backend.module.plot(pd.Series([1, 2, 3])) -The backend module can then use other visualization tools (Bokeh, Altair,...) +The backend module can then use other visualization tools (Bokeh, Altair, hvplot,...) to generate the plots. -Libraries implementing the plotting backend should use `entry points `__ -to make their backend discoverable to pandas. The key is ``"pandas_plotting_backends"``. For example, pandas -registers the default "matplotlib" backend as follows. - -.. code-block:: python - - # in setup.py - setup( # noqa: F821 - ..., - entry_points={ - "pandas_plotting_backends": [ - "matplotlib = pandas:plotting._matplotlib", - ], - }, - ) - +Developers guide can be found at +https://dev.pandas.io/docs/development/extending.html#plotting-backends More information on how to implement a third-party plotting backend can be found at https://github.com/pandas-dev/pandas/blob/master/pandas/plotting/__init__.py#L1. \ No newline at end of file From d9309e87eb162c561447ef96305458cb6d9f86e4 Mon Sep 17 00:00:00 2001 From: Rushabh Vasani Date: Mon, 3 Feb 2020 14:43:54 +0530 Subject: [PATCH 3/6] make requested changes --- doc/source/user_guide/visualization.rst | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/doc/source/user_guide/visualization.rst b/doc/source/user_guide/visualization.rst index ba14d5a41fd0e..47e22026f6b98 100644 --- a/doc/source/user_guide/visualization.rst +++ b/doc/source/user_guide/visualization.rst @@ -1645,7 +1645,7 @@ when plotting a large number of points. Plotting backends ----------------- -Starting in 0.25 pandas can be extended with third-party plotting backends. The +Starting in version 0.25, pandas can be extended with third-party plotting backends. The main idea is letting users select a plotting backend different than the provided one based on Matplotlib. For example: @@ -1673,7 +1673,4 @@ The backend module can then use other visualization tools (Bokeh, Altair, hvplot to generate the plots. Developers guide can be found at -https://dev.pandas.io/docs/development/extending.html#plotting-backends - -More information on how to implement a third-party plotting backend can be found at -https://github.com/pandas-dev/pandas/blob/master/pandas/plotting/__init__.py#L1. \ No newline at end of file +https://dev.pandas.io/docs/development/extending.html#plotting-backends \ No newline at end of file From c6f1040eceaaf115959e5bfb150084884dd113ad Mon Sep 17 00:00:00 2001 From: Rushabh Vasani Date: Tue, 4 Feb 2020 21:43:09 +0530 Subject: [PATCH 4/6] add one more mathod --- doc/source/user_guide/visualization.rst | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/doc/source/user_guide/visualization.rst b/doc/source/user_guide/visualization.rst index 47e22026f6b98..b45e162369717 100644 --- a/doc/source/user_guide/visualization.rst +++ b/doc/source/user_guide/visualization.rst @@ -1649,12 +1649,19 @@ Starting in version 0.25, pandas can be extended with third-party plotting backe main idea is letting users select a plotting backend different than the provided one based on Matplotlib. For example: +.. code-block:: python + + >>> Series([1,2,3]).plot(backend='backend.module') + +This can also be done by passsing 'backend.module' as the argument ``backend`` in ``plot`` +function. For example: + .. code-block:: python >>> pd.set_option('plotting.backend', 'backend.module') >>> pd.Series([1, 2, 3]).plot() -Same thing can be done by setting the ``pd.options.plotting.backend`` keyword +Same thing can also be done by setting the ``pd.options.plotting.backend`` keyword equals to 'backend.module'. For example: .. code-block:: python From a611600e9ba2daf87938898a20ee9c3d0322244d Mon Sep 17 00:00:00 2001 From: Joris Van den Bossche Date: Tue, 4 Feb 2020 17:49:27 +0100 Subject: [PATCH 5/6] fixup --- doc/source/user_guide/visualization.rst | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/doc/source/user_guide/visualization.rst b/doc/source/user_guide/visualization.rst index b45e162369717..4f81de907c62a 100644 --- a/doc/source/user_guide/visualization.rst +++ b/doc/source/user_guide/visualization.rst @@ -1647,22 +1647,24 @@ Plotting backends Starting in version 0.25, pandas can be extended with third-party plotting backends. The main idea is letting users select a plotting backend different than the provided -one based on Matplotlib. For example: +one based on Matplotlib. + +This can be done by passsing 'backend.module' as the argument ``backend`` in ``plot`` +function. For example: .. code-block:: python >>> Series([1,2,3]).plot(backend='backend.module') -This can also be done by passsing 'backend.module' as the argument ``backend`` in ``plot`` -function. For example: +Alternatively, you can also set this option globally, do you don't need to specify +the keyword in each ``plot`` call. For example: .. code-block:: python >>> pd.set_option('plotting.backend', 'backend.module') >>> pd.Series([1, 2, 3]).plot() -Same thing can also be done by setting the ``pd.options.plotting.backend`` keyword -equals to 'backend.module'. For example: +Or: .. code-block:: python @@ -1677,7 +1679,8 @@ This would be more or less equivalent to: >>> backend.module.plot(pd.Series([1, 2, 3])) The backend module can then use other visualization tools (Bokeh, Altair, hvplot,...) -to generate the plots. +to generate the plots. Some libraries implementing a backend for pandas are listed +on the ecosystem :ref:`ecosystem.visualization` page. Developers guide can be found at https://dev.pandas.io/docs/development/extending.html#plotting-backends \ No newline at end of file From 65660115ddb4a7aee1e87cfc9c8fe4ccd2bedf57 Mon Sep 17 00:00:00 2001 From: Rushabh Vasani Date: Wed, 5 Feb 2020 00:59:17 +0530 Subject: [PATCH 6/6] fix linting --- doc/source/user_guide/visualization.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/user_guide/visualization.rst b/doc/source/user_guide/visualization.rst index 4f81de907c62a..b0d63f9cd948a 100644 --- a/doc/source/user_guide/visualization.rst +++ b/doc/source/user_guide/visualization.rst @@ -1654,7 +1654,7 @@ function. For example: .. code-block:: python - >>> Series([1,2,3]).plot(backend='backend.module') + >>> Series([1, 2, 3]).plot(backend='backend.module') Alternatively, you can also set this option globally, do you don't need to specify the keyword in each ``plot`` call. For example: