Error when plotting with datetime indexes on a one month range
See original GitHub issueCode Sample, a copy-pastable example if possible
import pandas as pd
from matplotlib import pyplot as plt
l = []
for d in pd.date_range(pd.datetime(2017, 1, 1), pd.datetime(2017, 12, 31)):
l.append([d, 1])
data = pd.DataFrame(columns=['Date', 'Values'], data=l)
data.index = data['Date']
plt.figure()
data['Values'].plot() # should work
plt.show()
plt.figure()
data.loc[pd.datetime(2017, 1, 1):pd.datetime(2017, 1, 31)]['Values'].plot() # does not work for me
plt.show()
Problem description
The index of the dataframe are datetimes (everything works fine if they are just integers). When I plot the whole data, there is no error, but if I want to plot a single month, like in the second part of the code, then I get the error:
Exception in Tkinter callback
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/matplotlib/texmanager.py", line 486, in make_png
stderr=subprocess.STDOUT)
File "/usr/lib/python3.6/subprocess.py", line 336, in check_output
**kwargs).stdout
File "/usr/lib/python3.6/subprocess.py", line 418, in run
output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['dvipng', '-bg', 'Transparent', '-D', '100.0', '-T', 'tight', '-o', 'f5e9ce5af00a173bfe282bcbe3d5ed2e.png', '6be67e2d9c3c0e0576f96f57d2840f89.dvi']' returned non-zero exit status 1.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.6/tkinter/__init__.py", line 1699, in __call__
return self.func(*args)
File "/usr/lib/python3.6/tkinter/__init__.py", line 745, in callit
func(*args)
File "/usr/lib/python3.6/site-packages/matplotlib/backends/backend_tkagg.py", line 323, in idle_draw
self.draw()
File "/usr/lib/python3.6/site-packages/matplotlib/backends/backend_tkagg.py", line 304, in draw
FigureCanvasAgg.draw(self)
File "/usr/lib/python3.6/site-packages/matplotlib/backends/backend_agg.py", line 430, in draw
self.figure.draw(self.renderer)
File "/usr/lib/python3.6/site-packages/matplotlib/artist.py", line 55, in draw_wrapper
return draw(artist, renderer, *args, **kwargs)
File "/usr/lib/python3.6/site-packages/matplotlib/figure.py", line 1295, in draw
renderer, self, artists, self.suppressComposite)
File "/usr/lib/python3.6/site-packages/matplotlib/image.py", line 138, in _draw_list_compositing_images
a.draw(renderer)
File "/usr/lib/python3.6/site-packages/matplotlib/artist.py", line 55, in draw_wrapper
return draw(artist, renderer, *args, **kwargs)
File "/usr/lib/python3.6/site-packages/matplotlib/axes/_base.py", line 2399, in draw
mimage._draw_list_compositing_images(renderer, self, artists)
File "/usr/lib/python3.6/site-packages/matplotlib/image.py", line 138, in _draw_list_compositing_images
a.draw(renderer)
File "/usr/lib/python3.6/site-packages/matplotlib/artist.py", line 55, in draw_wrapper
return draw(artist, renderer, *args, **kwargs)
File "/usr/lib/python3.6/site-packages/matplotlib/axis.py", line 1138, in draw
tick.draw(renderer)
File "/usr/lib/python3.6/site-packages/matplotlib/artist.py", line 55, in draw_wrapper
return draw(artist, renderer, *args, **kwargs)
File "/usr/lib/python3.6/site-packages/matplotlib/axis.py", line 282, in draw
self.label1.draw(renderer)
File "/usr/lib/python3.6/site-packages/matplotlib/artist.py", line 55, in draw_wrapper
return draw(artist, renderer, *args, **kwargs)
File "/usr/lib/python3.6/site-packages/matplotlib/text.py", line 799, in draw
mtext=mtext)
File "/usr/lib/python3.6/site-packages/matplotlib/backends/backend_agg.py", line 250, in draw_tex
Z = texmanager.get_grey(s, size, self.dpi)
File "/usr/lib/python3.6/site-packages/matplotlib/texmanager.py", line 545, in get_grey
pngfile = self.make_png(tex, fontsize, dpi)
File "/usr/lib/python3.6/site-packages/matplotlib/texmanager.py", line 493, in make_png
exc.output.decode("utf-8"))))
RuntimeError: dvipng was not able to process the following string:
b''
Here is the full report generated by dvipng:
6be67e2d9c3c0e0576f96f57d2840f89.dvi: No such file or directory
This is dvipng (dvipng (TeX Live)) 1.15 Copyright 2002-2015 Jan-Ake Larsson
Exception in Tkinter callback
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/matplotlib/texmanager.py", line 486, in make_png
stderr=subprocess.STDOUT)
File "/usr/lib/python3.6/subprocess.py", line 336, in check_output
**kwargs).stdout
File "/usr/lib/python3.6/subprocess.py", line 418, in run
output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['dvipng', '-bg', 'Transparent', '-D', '100.0', '-T', 'tight', '-o', 'f5e9ce5af00a173bfe282bcbe3d5ed2e.png', '6be67e2d9c3c0e0576f96f57d2840f89.dvi']' returned non-zero exit status 1.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.6/tkinter/__init__.py", line 1699, in __call__
return self.func(*args)
File "/usr/lib/python3.6/site-packages/matplotlib/backends/backend_tkagg.py", line 233, in resize
self.show()
File "/usr/lib/python3.6/site-packages/matplotlib/backends/backend_tkagg.py", line 304, in draw
FigureCanvasAgg.draw(self)
File "/usr/lib/python3.6/site-packages/matplotlib/backends/backend_agg.py", line 430, in draw
self.figure.draw(self.renderer)
File "/usr/lib/python3.6/site-packages/matplotlib/artist.py", line 55, in draw_wrapper
return draw(artist, renderer, *args, **kwargs)
File "/usr/lib/python3.6/site-packages/matplotlib/figure.py", line 1295, in draw
renderer, self, artists, self.suppressComposite)
File "/usr/lib/python3.6/site-packages/matplotlib/image.py", line 138, in _draw_list_compositing_images
a.draw(renderer)
File "/usr/lib/python3.6/site-packages/matplotlib/artist.py", line 55, in draw_wrapper
return draw(artist, renderer, *args, **kwargs)
File "/usr/lib/python3.6/site-packages/matplotlib/axes/_base.py", line 2399, in draw
mimage._draw_list_compositing_images(renderer, self, artists)
File "/usr/lib/python3.6/site-packages/matplotlib/image.py", line 138, in _draw_list_compositing_images
a.draw(renderer)
File "/usr/lib/python3.6/site-packages/matplotlib/artist.py", line 55, in draw_wrapper
return draw(artist, renderer, *args, **kwargs)
File "/usr/lib/python3.6/site-packages/matplotlib/axis.py", line 1138, in draw
tick.draw(renderer)
File "/usr/lib/python3.6/site-packages/matplotlib/artist.py", line 55, in draw_wrapper
return draw(artist, renderer, *args, **kwargs)
File "/usr/lib/python3.6/site-packages/matplotlib/axis.py", line 282, in draw
self.label1.draw(renderer)
File "/usr/lib/python3.6/site-packages/matplotlib/artist.py", line 55, in draw_wrapper
return draw(artist, renderer, *args, **kwargs)
File "/usr/lib/python3.6/site-packages/matplotlib/text.py", line 799, in draw
mtext=mtext)
File "/usr/lib/python3.6/site-packages/matplotlib/backends/backend_agg.py", line 250, in draw_tex
Z = texmanager.get_grey(s, size, self.dpi)
File "/usr/lib/python3.6/site-packages/matplotlib/texmanager.py", line 545, in get_grey
pngfile = self.make_png(tex, fontsize, dpi)
File "/usr/lib/python3.6/site-packages/matplotlib/texmanager.py", line 493, in make_png
exc.output.decode("utf-8"))))
RuntimeError: dvipng was not able to process the following string:
b''
Here is the full report generated by dvipng:
6be67e2d9c3c0e0576f96f57d2840f89.dvi: No such file or directory
This is dvipng (dvipng (TeX Live)) 1.15 Copyright 2002-2015 Jan-Ake Larsson
I was using the TkAgg backend, but I had the same issue with the other backends as well.
Output of pd.show_versions()
INSTALLED VERSIONS
commit: None python: 3.6.2.final.0 python-bits: 64 OS: Linux OS-release: 4.13.7-1-ARCH machine: x86_64 processor: byteorder: little LC_ALL: None LANG: fr_FR.utf8 LOCALE: fr_FR.UTF-8
pandas: 0.20.3 pytest: 3.2.3 pip: 9.0.1 setuptools: 36.6.0 Cython: 0.27.1 numpy: 1.13.3 scipy: 0.19.1 xarray: None IPython: 6.2.1 sphinx: 1.6.4 patsy: None dateutil: 2.6.1 pytz: 2017.2 blosc: None bottleneck: 1.2.1 tables: None numexpr: 2.6.4 feather: None matplotlib: 2.1.0 openpyxl: None xlrd: 1.1.0 xlwt: 1.3.0 xlsxwriter: None lxml: None bs4: 4.6.0 html5lib: 0.999999999 sqlalchemy: 1.1.14 pymysql: None psycopg2: None jinja2: 2.9.6 s3fs: None pandas_gbq: None pandas_datareader: 0.5.0
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (2 by maintainers)
Top GitHub Comments
Seems like the error came from my matplotlibrc file. When I reset it, plotting with pandas works, so I close the issue.
I met the same problem today, @j4321 how did you fix that problem exactly?