我在画一个简单的横条图。为了可读性,我想用 关键字参数,但在执行此操作时,遇到一个未记录的必需参数的错误。在
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'
documentation中没有“bottom”参数:
^{pr2}$
目前没有回答
相关问题 更多 >
编程相关推荐