Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
125 views
in Technique[技术] by (71.8m points)

python - Matplotlib Labels Change Shades Of Grey

I tried running the exact same code on two different architectures (one Windows, one Linux). Same version of Matplotlib. The axes labels are written with different shades of grey (color is default black), as shown in the image. On the same machine, pixels are consistent between runs. The differnt behavior between machines causes bad scores in image comparison tests.

Does anyone know why this could happen, or if there is a way to enforce a certain behavior? I'd be happy also with just a binary color for labels, black/white.

enter image description here

question from:https://stackoverflow.com/questions/65886690/matplotlib-labels-change-shades-of-grey

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You can "force" whatever colour you like into the labels or anything actually. Assuming you have a figure, you can change:

  • spines. (Spines are the lines connecting the axis tick marks and noting the boundaries of the data area aka the borders of the plot)
ax.spines['bottom'].set_color('#dddddd')
ax.spines['top'].set_color('#dddddd') 
ax.spines['right'].set_color('red')
ax.spines['left'].set_color('red')
  • ticks (Ticks are the values used to show specific points on the coordinate axis aka the thing you're interested in, I think)
    ax.tick_params(axis='x', colors='red')
    ax.tick_params(axis='y', colors='red')
  • label
    ax.yaxis.label.set_color('red')
    ax.xaxis.label.set_color('red')

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...