Matplotlib: coloring axis/tick labels

后端 未结 2 1173
梦谈多话
梦谈多话 2020-12-09 10:03

How would one color y-axis label and tick labels in red?

So for example the \"y-label\" and values 0 through 40, to be colored in red.

2条回答
  •  天涯浪人
    2020-12-09 10:39

      label = plt.ylabel("y-label")
      label.set_color("red")
    

    similarly, you can obtain and modify the tick labels:

    [i.set_color("red") for i in plt.gca().get_xticklabels()]
    

提交回复
热议问题