Repository: pandas-dev/pandas

Issue:
Plotting Timedelta on y-axis
#### Code Sample

```python
import pandas as pd
from pandas.compat import StringIO
import matplotlib.pyplot as plt


dat = """c1,c2,c3
1000,2000,1500
9000,8000,1600"""

df = pd.read_csv(StringIO(dat))

print(df)

df.plot.bar()
plt.show()

df = df.apply(lambda x: pd.to_timedelta(x, unit='ms'))

print(df)

df.plot.bar()
plt.show()

```
#### Problem description

`plot.bar()` works with numerical values (`int`, `float`).

```
     c1    c2    c3
0  1000  2000  1500
1  9000  8000  1600
```

![capture d ecran 2017-07-15 a 20 20 30](https://user-images.githubusercontent.com/109167/28241986-6b0fb8e8-69a0-11e7-88d0-2c32de28af90.png)

not with `Timedelta`

```
        c1       c2              c3
0 00:00:01 00:00:02 00:00:01.500000
1 00:00:09 00:00:08 00:00:01.600000
```

```
    df.plot.bar()
  File "/Users/scls/anaconda/lib/python3.6/site-packages/pandas/plotting/_core.py", line 2659, in bar
    return self(kind='bar', x=x, y=y, **kwds)
  File "/Users/scls/anaconda/lib/python3.6/site-packages/pandas/plotting/_core.py", line 2620, in __call__
    sort_columns=sort_columns, **kwds)
  File "/Users/scls/anaconda/lib/python3.6/site-packages/pandas/plotting/_core.py", line 1857, in plot_frame
    **kwds)
  File "/Users/scls/anaconda/lib/python3.6/site-packages/pandas/plotting/_core.py", line 1682, in _plot
    plot_obj.generate()
  File "/Users/scls/anaconda/lib/python3.6/site-packages/pandas/plotting/_core.py", line 236, in generate
    self._compute_plot_data()
  File "/Users/scls/anaconda/lib/python3.6/site-packages/pandas/plotting/_core.py", line 345, in _compute_plot_data
    'plot'.format(numeric_data.__class__.__name__))
TypeError: Empty 'DataFrame': no numeric data to plot
```

#### Expected Output

Timedelta on y axis should be displayed

#### Output of ``pd.show_versions()``

<details>
/Users/scls/anaconda/lib/python3.6/site-packages/xarray/core/formatting.py:16: FutureWarning: The pandas.tslib module is deprecated and will be removed in a future version.
  from pandas.tslib import OutOfBoundsDatetime

INSTALLED VERSIONS
------------------
commit: None
python: 3.6.1.final.0
python-bits: 64
OS: Darwin
OS-release: 16.6.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: fr_FR.UTF-8
LOCALE: fr_FR.UTF-8

pandas: 0.20.1
pytest: 3.1.2
pip: 9.0.1
setuptools: 27.2.0
Cython: 0.25.2
numpy: 1.12.1
scipy: 0.19.0
xarray: 0.9.5
IPython: 5.3.0
sphinx: 1.5.6
patsy: 0.4.1
dateutil: 2.6.0
pytz: 2017.2
blosc: None
bottleneck: 1.2.1
tables: 3.3.0
numexpr: 2.6.2
feather: None
matplotlib: 2.0.2
openpyxl: 2.4.7
xlrd: 1.0.0
xlwt: 1.2.0
xlsxwriter: 0.9.6
lxml: 3.7.3
bs4: 4.6.0
html5lib: 0.999
sqlalchemy: 1.1.9
pymysql: None
psycopg2: None
jinja2: 2.9.6
s3fs: None
pandas_gbq: None
pandas_datareader: 0.4.0
</details>



Discussion:
I wonder if we could change https://github.com/pandas-dev/pandas/blob/3955261c04d5b838488a45fe7b186399bcdca137/pandas/plotting/_core.py#L343 to include `timedelta=True`? Maybe try changing that and seeing what breaks.
After changing

        numeric_data = data._convert(datetime=True)._get_numeric_data()

to

        numeric_data = data._convert(datetime=True, timedelta=True)._get_numeric_data()

it's still raising same exception
The `dtype`  of  ```data._convert(datetime=True, timedelta=True).values``` is `'timedelta64[ns]'` and they get filtered out by `_get_numeric_data()` because `TimeDeltaBlock.is_numeric = False`.
https://github.com/pandas-dev/pandas/blob/master/pandas/core/internals.py#L1705


` numeric_data = data._convert(datetime=True, timedelta=True)`
sort of works if you're fine with losing the timedelta format representation.

Got:
![figure_2](https://user-images.githubusercontent.com/3117729/28246036-efd0c030-6a0a-11e7-859d-c34df16e1c61.png)


Plotting `datetime64` on y-axis is also an issue.

```python
import pandas as pd
from pandas.compat import StringIO
import matplotlib.pyplot as plt


dat = """c1,c2,c3
1000,2000,1500
9000,8000,1600"""

df = pd.read_csv(StringIO(dat))

print(df)
print(df.dtypes)

# df.plot.bar()
# plt.show()

df = df.apply(lambda x: pd.to_timedelta(x, unit='ms'))
for col in df.columns:
    df[col] = df[col] + pd.to_datetime('1970/01/01')

print(df)
print(df.dtypes)

df.plot.bar()
plt.show()
```

see

```python
$ python mwe_pandas.py
     c1    c2    c3
0  1000  2000  1500
1  9000  8000  1600
c1    int64
c2    int64
c3    int64
dtype: object
                   c1                  c2                      c3
0 1970-01-01 00:00:01 1970-01-01 00:00:02 1970-01-01 00:00:01.500
1 1970-01-01 00:00:09 1970-01-01 00:00:08 1970-01-01 00:00:01.600
c1    datetime64[ns]
c2    datetime64[ns]
c3    datetime64[ns]
dtype: object
Traceback (most recent call last):
  File "mwe_pandas.py", line 27, in <module>
    df.plot.bar()
  File "/Users/scls/anaconda/lib/python3.6/site-packages/pandas/plotting/_core.py", line 2659, in bar
    return self(kind='bar', x=x, y=y, **kwds)
  File "/Users/scls/anaconda/lib/python3.6/site-packages/pandas/plotting/_core.py", line 2620, in __call__
    sort_columns=sort_columns, **kwds)
  File "/Users/scls/anaconda/lib/python3.6/site-packages/pandas/plotting/_core.py", line 1857, in plot_frame
    **kwds)
  File "/Users/scls/anaconda/lib/python3.6/site-packages/pandas/plotting/_core.py", line 1682, in _plot
    plot_obj.generate()
  File "/Users/scls/anaconda/lib/python3.6/site-packages/pandas/plotting/_core.py", line 236, in generate
    self._compute_plot_data()
  File "/Users/scls/anaconda/lib/python3.6/site-packages/pandas/plotting/_core.py", line 345, in _compute_plot_data
    'plot'.format(numeric_data.__class__.__name__))
TypeError: Empty 'DataFrame': no numeric data to plot
```

Resolving patch:
diff --git a/pandas/plotting/_core.py b/pandas/plotting/_core.py
--- a/pandas/plotting/_core.py
+++ b/pandas/plotting/_core.py
@@ -342,7 +342,13 @@ def _compute_plot_data(self):
                 label = 'None'
             data = data.to_frame(name=label)
 
-        numeric_data = data._convert(datetime=True)._get_numeric_data()
+        # 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"])
 
         try:
             is_empty = numeric_data.empty


Test patch:
diff --git a/pandas/tests/plotting/test_frame.py b/pandas/tests/plotting/test_frame.py
--- a/pandas/tests/plotting/test_frame.py
+++ b/pandas/tests/plotting/test_frame.py
@@ -380,6 +380,82 @@ def test_subplots_timeseries(self):
                 self._check_ticks_props(ax, xlabelsize=7, xrot=45,
                                         ylabelsize=7)
 
+    def test_subplots_timeseries_y_axis(self):
+        # GH16953
+        data = {"numeric": np.array([1, 2, 5]),
+                "timedelta": [pd.Timedelta(-10, unit="s"),
+                              pd.Timedelta(10, unit="m"),
+                              pd.Timedelta(10, unit="h")],
+                "datetime_no_tz": [pd.to_datetime("2017-08-01 00:00:00"),
+                                   pd.to_datetime("2017-08-01 02:00:00"),
+                                   pd.to_datetime("2017-08-02 00:00:00")],
+                "datetime_all_tz": [pd.to_datetime("2017-08-01 00:00:00",
+                                                   utc=True),
+                                    pd.to_datetime("2017-08-01 02:00:00",
+                                                   utc=True),
+                                    pd.to_datetime("2017-08-02 00:00:00",
+                                                   utc=True)],
+                "text": ["This", "should", "fail"]}
+        testdata = DataFrame(data)
+
+        ax_numeric = testdata.plot(y="numeric")
+        assert (ax_numeric.get_lines()[0].get_data()[1] ==
+                testdata["numeric"].values).all()
+        ax_timedelta = testdata.plot(y="timedelta")
+        assert (ax_timedelta.get_lines()[0].get_data()[1] ==
+                testdata["timedelta"].values).all()
+        ax_datetime_no_tz = testdata.plot(y="datetime_no_tz")
+        assert (ax_datetime_no_tz.get_lines()[0].get_data()[1] ==
+                testdata["datetime_no_tz"].values).all()
+        ax_datetime_all_tz = testdata.plot(y="datetime_all_tz")
+        assert (ax_datetime_all_tz.get_lines()[0].get_data()[1] ==
+                testdata["datetime_all_tz"].values).all()
+        with pytest.raises(TypeError):
+            testdata.plot(y="text")
+
+    @pytest.mark.xfail(reason='not support for period, categorical, '
+                       'datetime_mixed_tz')
+    def test_subplots_timeseries_y_axis_not_supported(self):
+        """
+        This test will fail for:
+            period:
+                since period isn't yet implemented in ``select_dtypes``
+                and because it will need a custom value converter +
+                tick formater (as was done for x-axis plots)
+
+            categorical:
+                 because it will need a custom value converter +
+                 tick formater (also doesn't work for x-axis, as of now)
+
+            datetime_mixed_tz:
+                because of the way how pandas handels ``Series`` of
+                ``datetime`` objects with different timezone,
+                generally converting ``datetime`` objects in a tz-aware
+                form could help with this problem
+        """
+        data = {"numeric": np.array([1, 2, 5]),
+                "period": [pd.Period('2017-08-01 00:00:00', freq='H'),
+                           pd.Period('2017-08-01 02:00', freq='H'),
+                           pd.Period('2017-08-02 00:00:00', freq='H')],
+                "categorical": pd.Categorical(["c", "b", "a"],
+                                              categories=["a", "b", "c"],
+                                              ordered=False),
+                "datetime_mixed_tz": [pd.to_datetime("2017-08-01 00:00:00",
+                                                     utc=True),
+                                      pd.to_datetime("2017-08-01 02:00:00"),
+                                      pd.to_datetime("2017-08-02 00:00:00")]}
+        testdata = pd.DataFrame(data)
+        ax_period = testdata.plot(x="numeric", y="period")
+        assert (ax_period.get_lines()[0].get_data()[1] ==
+                testdata["period"].values).all()
+        ax_categorical = testdata.plot(x="numeric", y="categorical")
+        assert (ax_categorical.get_lines()[0].get_data()[1] ==
+                testdata["categorical"].values).all()
+        ax_datetime_mixed_tz = testdata.plot(x="numeric",
+                                             y="datetime_mixed_tz")
+        assert (ax_datetime_mixed_tz.get_lines()[0].get_data()[1] ==
+                testdata["datetime_mixed_tz"].values).all()
+
     @pytest.mark.slow
     def test_subplots_layout(self):
         # GH 6667