Python 意外的必需参数';底部';在matplotlib.pyplot.barh()中
我正在画一个简单的水平条形图。为了可读性,我想使用 关键字参数,但在执行此操作时,我得到了一个带有未记录必需参数的错误Python 意外的必需参数';底部';在matplotlib.pyplot.barh()中,python,matplotlib,Python,Matplotlib,我正在画一个简单的水平条形图。为了可读性,我想使用 关键字参数,但在执行此操作时,我得到了一个带有未记录必需参数的错误 import pandas as pd import matplotlib.pyplot as plt plt.figure(figsize=(4,2)) # this example works plt.barh([1, 1, 1], [9.5, 8.5, 28.5], [.3, .3, .3], [-2207, -
import pandas as pd
import matplotlib.pyplot as plt
plt.figure(figsize=(4,2))
# this example works
plt.barh([1, 1, 1],
[9.5, 8.5, 28.5],
[.3, .3, .3],
[-2207, -2197, -2188])
# here I want to use keyword arguments for readability, according to
# https://matplotlib.org/api/_as_gen/matplotlib.pyplot.barh.html?highlight=barh
plt.barh(y=[1, 1, 1],
width= [9.5, 8.5, 28.5],
height = [.3, .3, .3],
left = [-2207, -2197, -2188])
# But I get error:
# File "<ipython-input-6-2f6ee5c89917>", line 4, in <module>
# left = [-2207, -2197, -2188])
# TypeError: barh() missing 1 required positional argument: 'bottom'
matplotlib版本“2.0.0”。我应该升级吗?是的,最新版本是2.2.2升级真的解决了这个问题,非常感谢!
bar(y, width, *, align='center', **kwargs)
bar(y, width, height, *, align='center', **kwargs)
bar(y, width, height, left, *, align='center', **kwargs)```