在 matplotlib 中使一些刻度标签比其他标签大

Make some tick labels larger than others in matplotlib

有没有办法只为 matplotlib 中的绘图制作某些刻度标签,或者比另一个更大?例如,我有一个 x 刻度标签列表,它们是设备名称,我想让最流行的标签比不常用的设备加粗或更大,有人知道如何实现吗?

基本示例如下:

import matplotlib.pyplot as plt
x = [1,2,3]
y = [2,4.5,4]
plt.plot(x,y)
plt.xticks([1,2,3], ['this', 'is', 'custom'])

font_sizes = [10,20,30]

for tick, size in zip(plt.xticks()[-1], font_sizes):
    tick.set_fontsize(size)

据我所知,你必须单独完成它们,而不是在某处提供列表..