Repository: pandas-dev/pandas

Issue:
Plotting boolean data fails
#### Code example
```python
import pandas as pd
df = pd.DataFrame({'data': [True, False, False]})
df['data'].plot()
```
#### Problem description
Plotting boolean data returns _TypeError: Empty 'DataFrame': no numeric data to plot_. 
Matplotlib interprets boolean data as 0/1, which allows plotting.

#### Expected Output
A plot of the boolean data like matplotlib would make (interpreting True/False as 1/0).

#### Output of ``pd.show_versions()``

<details>

[paste the output of ``pd.show_versions()`` here below this line]
INSTALLED VERSIONS
------------------
commit: None
python: 3.6.4.final.0
python-bits: 64
OS: Windows
OS-release: 7
machine: AMD64
processor: Intel64 Family 6 Model 78 Stepping 3, GenuineIntel
byteorder: little
LC_ALL: None
LANG: en
LOCALE: None.None

pandas: 0.23.4
pytest: 3.3.2
pip: 9.0.1
setuptools: 38.4.0
Cython: 0.27.3
numpy: 1.14.2
scipy: 1.0.0
pyarrow: None
xarray: 0.10.9
IPython: 6.2.1
sphinx: 1.6.6
patsy: 0.5.0
dateutil: 2.6.1
pytz: 2017.3
blosc: None
bottleneck: 1.2.1
tables: 3.4.2
numexpr: 2.6.4
feather: None
matplotlib: 2.1.2
openpyxl: 2.4.10
xlrd: 1.1.0
xlwt: 1.3.0
xlsxwriter: 1.0.2
lxml: 4.1.1
bs4: 4.6.0
html5lib: 1.0.1
sqlalchemy: 1.2.1
pymysql: None
psycopg2: None
jinja2: 2.10
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None

</details>



Discussion:
@BSchilperoort : Good catch!  Investigation and PR are welcome!

cc @TomAugspurger 
Added the simple fix in a PR: #23813


Resolving patch:
diff --git a/pandas/plotting/_core.py b/pandas/plotting/_core.py
--- a/pandas/plotting/_core.py
+++ b/pandas/plotting/_core.py
@@ -586,6 +586,8 @@ class PlotAccessor(PandasObject):
     mark_right : bool, default True
         When using a secondary_y axis, automatically mark the column
         labels with "(right)" in the legend
+    include_bool : bool, default is False
+        If True, boolean values can be plotted
     `**kwds` : keywords
         Options to pass to matplotlib plotting method
 
diff --git a/pandas/plotting/_matplotlib/core.py b/pandas/plotting/_matplotlib/core.py
--- a/pandas/plotting/_matplotlib/core.py
+++ b/pandas/plotting/_matplotlib/core.py
@@ -106,6 +106,7 @@ def __init__(
         colormap=None,
         table=False,
         layout=None,
+        include_bool=False,
         **kwds
     ):
 
@@ -191,6 +192,7 @@ def __init__(
             self.colormap = colormap
 
         self.table = table
+        self.include_bool = include_bool
 
         self.kwds = kwds
 
@@ -400,9 +402,12 @@ def _compute_plot_data(self):
         # GH16953, _convert is needed as fallback, for ``Series``
         # with ``dtype == object``
         data = data._convert(datetime=True, timedelta=True)
-        numeric_data = data.select_dtypes(
-            include=[np.number, "datetime", "datetimetz", "timedelta"]
-        )
+        select_include_type = [np.number, "datetime", "datetimetz", "timedelta"]
+
+        # GH23719, allow plotting boolean
+        if self.include_bool is True:
+            select_include_type.append(np.bool_)
+        numeric_data = data.select_dtypes(include=select_include_type)
 
         try:
             is_empty = numeric_data.empty


Test patch:
diff --git a/pandas/tests/plotting/test_series.py b/pandas/tests/plotting/test_series.py
--- a/pandas/tests/plotting/test_series.py
+++ b/pandas/tests/plotting/test_series.py
@@ -167,6 +167,15 @@ def test_label(self):
         ax.legend()  # draw it
         self._check_legend_labels(ax, labels=["LABEL"])
 
+    def test_boolean(self):
+        # GH 23719
+        s = Series([False, False, True])
+        _check_plot_works(s.plot, include_bool=True)
+
+        msg = "no numeric data to plot"
+        with pytest.raises(TypeError, match=msg):
+            _check_plot_works(s.plot)
+
     def test_line_area_nan_series(self):
         values = [1, 2, np.nan, 3]
         s = Series(values)