首页 > 解决方案 > 如何在 matplotlib 子图中设置属性?

问题描述

我想在 matplotlib 中制作子图并设置不同的属性:但我有一个错误 'AxesSubplot' object has no attribute 'setp'

fig, ax = plt.subplots()

ax.axvline(x=654.31, linewidth=4, ls = '--', color = 'Gold' )

(markers, stemlines, baseline) = ax.stem(dfs.index, dfs.RTCM)
ax.setp(stemlines, linestyle="-", color="olive", linewidth=0.5 )

我找不到解决问题的方法。我将不胜感激。

标签: python-3.xmatplotlibsubplot

解决方案


可以直接在stem函数中设置线条格式和颜色

ax.stem(dfs.index, dfs.RTCM, linefmt='C4-', markerfmt='D')

推荐阅读