Skip to content

Improve plotting Timedelta on y-axis (Timedelta string representation) #17553

Open
@s-celles

Description

@s-celles

Code Sample, a copy-pastable example if possible

Following #9154 (comment) and #16953 (comment)

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()

Displays

        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

figure_1-1

Problem description

Y-axis should display Timedelta string representation (not integer values)

Expected Output

Output of pd.show_versions()

[paste the output of pd.show_versions() here below this line]

pd.show_versions()

INSTALLED VERSIONS

commit: 328c7e1
python: 3.6.2.final.0
python-bits: 64
OS: Darwin
OS-release: 16.7.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: fr_FR.UTF-8
LOCALE: fr_FR.UTF-8

pandas: 0.21.0.dev+464.g328c7e179
pytest: 3.2.1
pip: 9.0.1
setuptools: 36.4.0
Cython: 0.26
numpy: 1.13.1
scipy: None
pyarrow: None
xarray: None
IPython: None
sphinx: None
patsy: None
dateutil: 2.6.1
pytz: 2017.2
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: 2.0.2
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: None
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions