Python 在散点图中设置errorbar样式失败

Python 在散点图中设置errorbar样式失败,python,pandas,matplotlib,plot,Python,Pandas,Matplotlib,Plot,我需要创建一个带有错误条的散点图,并配置错误条样式。虽然这对简单绘图功能有效,但对散点图无效: import pandas as pd import matplotlib.pyplot as plt import numpy as np df = pd.DataFrame(np.random.random(15).reshape(5, 3), columns=['x', 'y', 'yerr']) # WORKS df.plot(x='x', y='y',

我需要创建一个带有错误条的散点图,并配置错误条样式。虽然这对简单绘图功能有效,但对散点图无效:

import pandas as pd
import matplotlib.pyplot as plt
import numpy as np

df = pd.DataFrame(np.random.random(15).reshape(5, 3),
                  columns=['x', 'y', 'yerr'])

# WORKS
df.plot(x='x', y='y', yerr='yerr', capsize=10, capthick=10, linestyle='None')
plt.show()

# WORKS
df.plot.scatter(x='x', y='y', yerr='yerr')
plt.show()

# FAILS
df.plot.scatter(x='x', y='y', yerr='yerr', capsize=10, capthick=10)
plt.show()
上面的代码给出了最后一个plot命令的以下错误:

20201102_debug_pandas_plotting_issue.py", line 17, in <module>
    df.plot.scatter(x='x', y='y', yerr='yerr', capsize=10, capthick=10)
  File "/home/user/miniconda/envs/testing/lib/python3.7/site-packages/pandas/plotting/_core.py", line 1613, in scatter
    return self(kind="scatter", x=x, y=y, s=s, c=c, **kwargs)
  File "/home/user/miniconda/envs/testing/lib/python3.7/site-packages/pandas/plotting/_core.py", line 894, in __call__
    return plot_backend.plot(data, x=x, y=y, kind=kind, **kwargs)
  File "/home/user/miniconda/envs/testing/lib/python3.7/site-packages/pandas/plotting/_matplotlib/__init__.py", line 61, in plot
    plot_obj.generate()
  File "/home/user/miniconda/envs/testing/lib/python3.7/site-packages/pandas/plotting/_matplotlib/core.py", line 271, in generate
    self._make_plot()
  File "/home/user/miniconda/envs/testing/lib/python3.7/site-packages/pandas/plotting/_matplotlib/core.py", line 1016, in _make_plot
    **self.kwds,
  File "/home/user/miniconda/envs/testing/lib/python3.7/site-packages/matplotlib/__init__.py", line 1438, in inner
    return func(ax, *map(sanitize_sequence, args), **kwargs)
  File "/home/user/miniconda/envs/testing/lib/python3.7/site-packages/matplotlib/cbook/deprecation.py", line 411, in wrapper
    return func(*inner_args, **inner_kwargs)
  File "/home/user/miniconda/envs/testing/lib/python3.7/site-packages/matplotlib/axes/_axes.py", line 4498, in scatter
    collection.update(kwargs)
  File "/home/user/miniconda/envs/testing/lib/python3.7/site-packages/matplotlib/artist.py", line 996, in update
    raise AttributeError(f"{type(self).__name__!r} object "
AttributeError: 'PathCollection' object has no property 'capsize'

类似于
fig,ax=plt.subplot()
ax.errorbar(df['x'],df['y'],df['yerr'],fmt='o',capthick=10,capthick=10)
,类似于
fig,ax=plt.subplot(),
ax.errorbar(df['x'],df['y'],df['yerr'],fmt='o',capthick=10,capthick=10)
$ conda list | grep matplotlib
matplotlib                3.3.2                         0  
matplotlib-base           3.3.2            py37h817c723_0 
$ conda list | grep pandas
pandas                    1.1.3            py37he6710b0_0