关于python:Matplotlib – AttributeError:未知的属性制造商

Matplotlib - AttributeError: Unknown property maker

我的代码:

1
2
3
4
5
6
7
from matplotlib import pyplot as plt
years = [1950, 1960, 1970, 1980, 1990, 2000, 2010]
gdp =  [300.2, 543.3, 1075.9, 286.5, 5979.6, 10289.7, 14958.3]
plt.plot(years, gdp, color= 'green', maker='o', linestyle= 'solid')
plt.title("Nominal GDP")
plt.ylabel("Billions of $")
plt.show()

我在Python 3.6.2中运行这个程序但是我遇到了各种错误。 以下是我得到的错误

Traceback (most recent call last):

File"C:\Python Programs\Python 3.4\test1.py", line 6, in
plt.plot(years, gdp, color= 'green', maker='o', linestyle= 'solid')

File"C:\Program Files (x86)\Python36-32\lib\site-packages\matplotlib\pyplot.py", line 3317, in plot
ret = ax.plot(*args, **kwargs)

File"C:\Program Files (x86)\Python36-32\lib\site-packages\matplotlib__init__.py", line 1898, in inner
return func(ax, *args, **kwargs)

File"C:\Program Files (x86)\Python36-32\lib\site-packages\matplotlib\axes_axes.py", line 1406, in plot
for line in self._get_lines(*args, **kwargs):

File"C:\Program Files (x86)\Python36-32\lib\site-packages\matplotlib\axes_base.py", line 407, in _grab_next_args
for seg in self._plot_args(remaining, kwargs):

File"C:\Program Files (x86)\Python36-32\lib\site-packages\matplotlib\axes_base.py", line 395, in _plot_args
seg = func(x[:, j % ncx], y[:, j % ncy], kw, kwargs)

File"C:\Program Files (x86)\Python36-32\lib\site-packages\matplotlib\axes_base.py", line 302, in _makeline
seg = mlines.Line2D(x, y, **kw)

File"C:\Program Files (x86)\Python36-32\lib\site-packages\matplotlib\lines.py", line 431, in init
self.update(kwargs)

File"C:\Program Files (x86)\Python36-32\lib\site-packages\matplotlib\artist.py", line 885, in update
for k, v in props.items()]

File"C:\Program Files (x86)\Python36-32\lib\site-packages\matplotlib\artist.py", line 885, in
for k, v in props.items()]

File"C:\Program Files (x86)\Python36-32\lib\site-packages\matplotlib\artist.py", line 878, in _update_property
raise AttributeError('Unknown property %s' % k)

AttributeError: Unknown property maker

有人可以帮忙吗?


pl.plot()的Matplotlib文档:

marker: :mod:A valid marker style

因此,在plot()调用中将maker更改为marker