如何为子地块中的多个绘图更改错误条的颜色?

2024-06-07 09:47:57 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个子地块,有多个线形图。每个都有一个错误条。数据来自我使用pandas读取的excel表格。一些错误条相互重叠。这就是为什么我想用线条图的颜色给每个错误条上色。有这样做的选择吗

到目前为止,我已经尝试过:

colors = ['blue','green','orange']

fig, ax = plt.subplots()
df_roughness_1030_CuSn6.groupby('Speed').plot(x= 'Power', y='Mean(Ra)', ax=ax)

plt.errorbar(df_roughness_1030_CuSn6['Power'], df_roughness_1030_CuSn6['Mean(Ra)'],yerr=yerror_roughness_1030_CuSn6, fmt='.k', marker= 'D', ecolor=colors, elinewidth=2, markersize=6, capsize=3, capthick=1,linestyle='none', label= 'standarddeviation')
plt.legend(('50 mm/s', '100 mm/s', '200 mm/s'), loc='upper left')
plt.title("CuSn6 1030 nm - Keyence ", fontsize= 12)

ax.set_xticks(major_ticks_1030_CuSn6)

ax.set_yticks(minor_ticks_1030_CuSn6_y, minor=True)
ax.set_yticks(minor_ticks_1030_CuSn6_y_2, minor=True)
ax.set_yticks(major_ticks_1030_CuSn6_y)

ax.grid(which='both')
ax.grid(which='major', alpha=1)
ax.grid(which='minor', alpha=0.5)

ax.set_xlabel('Power [W]')
ax.set_ylabel(r'$\mathrm{R_a\ [µm]}$')

然而,这似乎并不正确。plt.errorbar的ecolor无法读取颜色列表


Tags: dfwhich错误pltaxgridmmpower

热门问题