0

When I use %matplotlib inline in my program, I get a ValueError. What does this error mean, and how can I resolve it?

Here is the error:

Traceback (most recent call last):
File "main.py", line 40, in <module>
ct.iloc[:-1,:-1].plot(kind='bar',stacked=True,color=['red','blue'],grid='false')
File "/usr/lib/python2.7/dist-packages/pandas/tools/plotting.py", line  1735, in plot_frame
plot_obj.generate()
File "/usr/lib/python2.7/dist-packages/pandas/tools/plotting.py", line 907, in generate
self._adorn_subplots()
File "/usr/lib/python2.7/dist-packages/pandas/tools/plotting.py", line  1012, in _adorn_subplots
ax.grid(self.grid)
File "/usr/lib/pymodules/python2.7/matplotlib/axes.py", line 2176, in grid
b = _string_to_bool(b)
File "/usr/lib/pymodules/python2.7/matplotlib/axes.py", line 54, in _string_to_bool
raise ValueError("string argument must be either 'on' or 'off'")
ValueError: string argument must be either 'on' or 'off'

1 Answer 1

3

Using the final line of your traceback can be very useful. One of the string arguments you are passing should only be 'on' or 'off'. Based on this we can then look at the grid option as this is a boolean option.

I tested this like so:

%matplotlib inline
import matplotlib.pyplot as plt
plt.plot([23,4],[4,6])
plt.grid('false')

giving the same error you got. To fix this you should use either grid = 'off' or grid = False as options. In my example above I would change that to plt.grid('off')

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.