Skip to content

Commit 2f8fea7

Browse files
gfyoungjreback
authored andcommitted
CLN: Removed trellis rplot
xref pandas-dev#9357. Title is self- explanatory. Author: gfyoung <[email protected]> Closes pandas-dev#13855 from gfyoung/trellis-plot-remove and squashes the following commits: 5427086 [gfyoung] CLN: Removed trellis rplot
1 parent a7f7e1d commit 2f8fea7

File tree

4 files changed

+7
-1543
lines changed

4 files changed

+7
-1543
lines changed

doc/source/visualization.rst

+5-243
Original file line numberDiff line numberDiff line change
@@ -1615,246 +1615,8 @@ Trellis plotting interface
16151615

16161616
.. warning::
16171617

1618-
The ``rplot`` trellis plotting interface is **deprecated and will be removed
1619-
in a future version**. We refer to external packages like
1620-
`seaborn <https://github.com/mwaskom/seaborn>`_ for similar but more
1621-
refined functionality.
1622-
1623-
The docs below include some example on how to convert your existing code to
1624-
``seaborn``.
1625-
1626-
.. ipython:: python
1627-
:suppress:
1628-
1629-
tips_data = pd.read_csv('data/tips.csv')
1630-
iris_data = pd.read_csv('data/iris.data')
1631-
plt.close('all')
1632-
1633-
1634-
.. note::
1635-
1636-
The tips data set can be downloaded `here
1637-
<https://raw.github.com/pydata/pandas/master/pandas/tests/data/tips.csv>`__. Once you download it execute
1638-
1639-
.. code-block:: python
1640-
1641-
tips_data = pd.read_csv('tips.csv')
1642-
1643-
from the directory where you downloaded the file.
1644-
1645-
We import the rplot API:
1646-
1647-
.. ipython:: python
1648-
:okwarning:
1649-
1650-
import pandas.tools.rplot as rplot
1651-
1652-
Examples
1653-
~~~~~~~~
1654-
1655-
RPlot was an API for producing Trellis plots. These plots allow you to
1656-
arrange data in a rectangular grid by values of certain attributes.
1657-
In the example below, data from the tips data set is arranged by the attributes
1658-
'sex' and 'smoker'. Since both of those attributes can take on one of two
1659-
values, the resulting grid has two columns and two rows. A histogram is
1660-
displayed for each cell of the grid.
1661-
1662-
.. ipython:: python
1663-
:okwarning:
1664-
1665-
plt.figure()
1666-
1667-
plot = rplot.RPlot(tips_data, x='total_bill', y='tip')
1668-
plot.add(rplot.TrellisGrid(['sex', 'smoker']))
1669-
plot.add(rplot.GeomHistogram())
1670-
1671-
@savefig rplot1_tips.png
1672-
plot.render(plt.gcf())
1673-
1674-
.. ipython:: python
1675-
:suppress:
1676-
1677-
plt.close('all')
1678-
1679-
A similar plot can be made with ``seaborn`` using the ``FacetGrid`` object,
1680-
resulting in the following image:
1681-
1682-
.. code-block:: python
1683-
1684-
import seaborn as sns
1685-
g = sns.FacetGrid(tips_data, row="sex", col="smoker")
1686-
g.map(plt.hist, "total_bill")
1687-
1688-
.. image:: _static/rplot-seaborn-example1.png
1689-
1690-
1691-
Example below is the same as previous except the plot is set to kernel density
1692-
estimation. A ``seaborn`` example is included beneath.
1693-
1694-
.. ipython:: python
1695-
:okwarning:
1696-
1697-
plt.figure()
1698-
1699-
plot = rplot.RPlot(tips_data, x='total_bill', y='tip')
1700-
plot.add(rplot.TrellisGrid(['sex', 'smoker']))
1701-
plot.add(rplot.GeomDensity())
1702-
1703-
@savefig rplot2_tips.png
1704-
plot.render(plt.gcf())
1705-
1706-
.. ipython:: python
1707-
:suppress:
1708-
1709-
plt.close('all')
1710-
1711-
.. code-block:: python
1712-
1713-
g = sns.FacetGrid(tips_data, row="sex", col="smoker")
1714-
g.map(sns.kdeplot, "total_bill")
1715-
1716-
.. image:: _static/rplot-seaborn-example2.png
1717-
1718-
The plot below shows that it is possible to have two or more plots for the same
1719-
data displayed on the same Trellis grid cell.
1720-
1721-
.. ipython:: python
1722-
:okwarning:
1723-
1724-
plt.figure()
1725-
1726-
plot = rplot.RPlot(tips_data, x='total_bill', y='tip')
1727-
plot.add(rplot.TrellisGrid(['sex', 'smoker']))
1728-
plot.add(rplot.GeomScatter())
1729-
plot.add(rplot.GeomPolyFit(degree=2))
1730-
1731-
@savefig rplot3_tips.png
1732-
plot.render(plt.gcf())
1733-
1734-
.. ipython:: python
1735-
:suppress:
1736-
1737-
plt.close('all')
1738-
1739-
A seaborn equivalent for a simple scatter plot:
1740-
1741-
.. code-block:: python
1742-
1743-
g = sns.FacetGrid(tips_data, row="sex", col="smoker")
1744-
g.map(plt.scatter, "total_bill", "tip")
1745-
1746-
.. image:: _static/rplot-seaborn-example3.png
1747-
1748-
and with a regression line, using the dedicated ``seaborn`` ``regplot`` function:
1749-
1750-
.. code-block:: python
1751-
1752-
g = sns.FacetGrid(tips_data, row="sex", col="smoker", margin_titles=True)
1753-
g.map(sns.regplot, "total_bill", "tip", order=2)
1754-
1755-
.. image:: _static/rplot-seaborn-example3b.png
1756-
1757-
1758-
Below is a similar plot but with 2D kernel density estimation plot superimposed,
1759-
followed by a ``seaborn`` equivalent:
1760-
1761-
.. ipython:: python
1762-
:okwarning:
1763-
1764-
plt.figure()
1765-
1766-
plot = rplot.RPlot(tips_data, x='total_bill', y='tip')
1767-
plot.add(rplot.TrellisGrid(['sex', 'smoker']))
1768-
plot.add(rplot.GeomScatter())
1769-
plot.add(rplot.GeomDensity2D())
1770-
1771-
@savefig rplot4_tips.png
1772-
plot.render(plt.gcf())
1773-
1774-
.. ipython:: python
1775-
:suppress:
1776-
1777-
plt.close('all')
1778-
1779-
.. code-block:: python
1780-
1781-
g = sns.FacetGrid(tips_data, row="sex", col="smoker")
1782-
g.map(plt.scatter, "total_bill", "tip")
1783-
g.map(sns.kdeplot, "total_bill", "tip")
1784-
1785-
.. image:: _static/rplot-seaborn-example4.png
1786-
1787-
It is possible to only use one attribute for grouping data. The example above
1788-
only uses 'sex' attribute. If the second grouping attribute is not specified,
1789-
the plots will be arranged in a column.
1790-
1791-
.. ipython:: python
1792-
:okwarning:
1793-
1794-
plt.figure()
1795-
1796-
plot = rplot.RPlot(tips_data, x='total_bill', y='tip')
1797-
plot.add(rplot.TrellisGrid(['sex', '.']))
1798-
plot.add(rplot.GeomHistogram())
1799-
1800-
@savefig rplot5_tips.png
1801-
plot.render(plt.gcf())
1802-
1803-
.. ipython:: python
1804-
:suppress:
1805-
1806-
plt.close('all')
1807-
1808-
If the first grouping attribute is not specified the plots will be arranged in a row.
1809-
1810-
.. ipython:: python
1811-
:okwarning:
1812-
1813-
plt.figure()
1814-
1815-
plot = rplot.RPlot(tips_data, x='total_bill', y='tip')
1816-
plot.add(rplot.TrellisGrid(['.', 'smoker']))
1817-
plot.add(rplot.GeomHistogram())
1818-
1819-
@savefig rplot6_tips.png
1820-
plot.render(plt.gcf())
1821-
1822-
.. ipython:: python
1823-
:suppress:
1824-
1825-
plt.close('all')
1826-
1827-
In ``seaborn``, this can also be done by only specifying one of the ``row``
1828-
and ``col`` arguments.
1829-
1830-
In the example below the colour and shape of the scatter plot graphical
1831-
objects is mapped to 'day' and 'size' attributes respectively. You use
1832-
scale objects to specify these mappings. The list of scale classes is
1833-
given below with initialization arguments for quick reference.
1834-
1835-
.. ipython:: python
1836-
:okwarning:
1837-
1838-
plt.figure()
1839-
1840-
plot = rplot.RPlot(tips_data, x='tip', y='total_bill')
1841-
plot.add(rplot.TrellisGrid(['sex', 'smoker']))
1842-
plot.add(rplot.GeomPoint(size=80.0, colour=rplot.ScaleRandomColour('day'), shape=rplot.ScaleShape('size'), alpha=1.0))
1843-
1844-
@savefig rplot7_tips.png
1845-
plot.render(plt.gcf())
1846-
1847-
.. ipython:: python
1848-
:suppress:
1849-
1850-
plt.close('all')
1851-
1852-
This can also be done in ``seaborn``, at least for 3 variables:
1853-
1854-
.. code-block:: python
1855-
1856-
g = sns.FacetGrid(tips_data, row="sex", col="smoker", hue="day")
1857-
g.map(plt.scatter, "tip", "total_bill")
1858-
g.add_legend()
1859-
1860-
.. image:: _static/rplot-seaborn-example6.png
1618+
The ``rplot`` trellis plotting interface has been **removed**. Please use
1619+
external packages like `seaborn <https://github.com/mwaskom/seaborn>`_ for
1620+
similar but more refined functionality and refer to our 0.18.1 documentation
1621+
`here <http://pandas.pydata.org/pandas-docs/version/0.18.1/visualization.html>`__
1622+
for how to convert to using it.

doc/source/whatsnew/v0.19.0.txt

+2
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,8 @@ Removal of prior version deprecations/changes
693693
- The ``pd.sandbox`` module has been removed in favor of the external library ``pandas-qt`` (:issue:`13670`)
694694
- The ``pandas.io.data`` and ``pandas.io.wb`` modules are removed in favor of
695695
the `pandas-datareader package <https://github.com/pydata/pandas-datareader>`__ (:issue:`13724`).
696+
- The ``pandas.tools.rplot`` module has been removed in favor of
697+
the `seaborn package <https://github.com/mwaskom/seaborn>`__ (:issue:`13855`)
696698
- ``DataFrame.to_csv()`` has dropped the ``engine`` parameter, as was deprecated in 0.17.1 (:issue:`11274`, :issue:`13419`)
697699
- ``DataFrame.to_dict()`` has dropped the ``outtype`` parameter in favor of ``orient`` (:issue:`13627`, :issue:`8486`)
698700
- ``pd.Categorical`` has dropped setting of the ``ordered`` attribute directly in favor of the ``set_ordered`` method (:issue:`13671`)

0 commit comments

Comments
 (0)