0

I am plotting a dataframe:

        ax = df.plot()
        fig = ax.get_figure()
        fig.savefig("{}/{}ts.png".format(IMGPATH, series[pfxlen:]))

It works fine. But, on the console, I get:

/usr/lib64/python2.7/site-packages/matplotlib/axes.py:2542: UserWarning: Attempting to set identical left==right results in singular transformations; automatically expanding. left=736249.924955, right=736249.924955 + 'left=%s, right=%s') % (left, right))

Basic searching hasn't showed me how to solve this error. So, I want to suppress these errors, since they garbage up the console. How can I do this?

4
  • Are you only plotting one datapoint or a series of data with the same x value? Commented Oct 13, 2016 at 18:52
  • @wflynny - this is a time series read from InfluxDB to the dataframe. It contains time and a measurement (float). Commented Oct 13, 2016 at 18:54
  • 1
    So I take it that you are plotting a single datapoint. Somewhere, either in your code or within df.plot(), you are calling ax.set_xlim(736249.924955, 736249.924955) and that's what matplotlib is complaining about. Commented Oct 13, 2016 at 19:06
  • @wflynny - Indeed. Since df.plot() is out of my control, I'd like to suppress the error messages to terminal, if possible. Commented Oct 13, 2016 at 19:11

1 Answer 1

3

Those aren't errors, but warnings. If you aren't concerned by those and just want to silence them, it's as simple as:

import warnings
warnings.filterwarnings('ignore')

Additionally, pandas and other libraries may trigger NumPY floating-point errors. If you encounter those, you have to silence them as well:

import numpy as np
np.seterr('ignore')
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.