Python 2.7 %matplotlib内联值错误
当我在程序中使用%matplotlib内联时,我得到一个ValueError。这个错误是什么意思?我如何解决它 以下是错误:Python 2.7 %matplotlib内联值错误,python-2.7,matplotlib,Python 2.7,Matplotlib,当我在程序中使用%matplotlib内联时,我得到一个ValueError。这个错误是什么意思?我如何解决它 以下是错误: 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/dis
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'
回溯(最近一次呼叫最后一次):
文件“main.py”,第40行,在
ct.iloc[:-1,:-1]。绘图(kind='bar',stacked=True,color='red','blue'],grid='false')
文件“/usr/lib/python2.7/dist packages/pandas/tools/plotting.py”,第1735行,在plot_框架中
绘图对象生成()
文件“/usr/lib/python2.7/dist packages/pandas/tools/plotting.py”,第907行,在generate中
自我装饰子图()
文件“/usr/lib/python2.7/dist packages/pandas/tools/plotting.py”,第1012行,位于装饰子图中
ax.grid(self.grid)
文件“/usr/lib/pymodules/python2.7/matplotlib/axes.py”,第2176行,网格中
b=_字符串_到_布尔(b)
文件“/usr/lib/pymodules/python2.7/matplotlib/axes.py”,第54行,在字符串中
raise VALUERROR(“字符串参数必须为“开”或“关”)
ValueError:字符串参数必须为“开”或“关”
提问时,应遵循以下指南:
而不是仅仅发布回溯
也就是说,回溯非常有用,根据你的回溯,你将能够找出问题所在
使用回溯的最后一行可能非常有用。您要传递的字符串参数之一应仅为'on'
或'off'
。基于此,我们可以查看网格选项,因为这是一个布尔选项
我是这样测试的:
%matplotlib inline
import matplotlib.pyplot as plt
plt.plot([23,4],[4,6])
plt.grid('false')
给你同样的错误。
要解决此问题,应使用
grid='off'
或grid=False
作为选项。在上面的示例中,我将其更改为plt.grid('off')
当您提出问题时,应遵循以下指南:
而不是仅仅发布回溯
也就是说,回溯非常有用,根据你的回溯,你将能够找出问题所在
使用回溯的最后一行可能非常有用。您要传递的字符串参数之一应仅为'on'
或'off'
。基于此,我们可以查看网格选项,因为这是一个布尔选项
我是这样测试的:
%matplotlib inline
import matplotlib.pyplot as plt
plt.plot([23,4],[4,6])
plt.grid('false')
给你同样的错误。
要解决此问题,应使用grid='off'
或grid=False
作为选项。在上面的示例中,我将其更改为plt.grid('off')