用记号匹配打印颜色

2024-10-02 18:15:49 发布

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

我正在用横条画一个图,包括双轴。你知道吗

我希望记号的颜色与条形图的颜色完全相同,也就是说,包括参数“alpha”。你知道吗

但是我不能给他们这个参数。你知道吗

有什么解决办法吗?你知道吗

下面是一段相关代码:

# Drawing the bar plot:

rects1 = ax1.bar(x_axis, y_values, bar_width, color='magenta', alpha = 0.4)

# Playing with color for the bars

ax1.set_ylabel('Charge value [nC]', color='magenta', alpha = 0.4)

# Get the ticks and copy color HERE DOES NOT WORK

for tl in ax1.get_yticklabels():
 tl.set_color(color='magenta', alpha = 0.4)

回溯:

tl.set_color(color='magenta', alpha = 0.4)
TypeError: set_color() got an unexpected keyword argument 'alpha'

Tags: thealphafor参数颜色barcolor条形图