原始代码,如下所示:
import matplotlib.pyplot as plt
ages_x = [25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35]
dev_y...= [38496, 42000, 46752, 49320, 53200, 56000, 62316, 64928, 67317, 68748, 73752]
plt.bar(ages_x,dev_y...,label='开发者年龄与薪资')
plt.xlabel('年龄')
plt.ylabel('薪资')
plt.show()
得到的x轴是浮点数,如下图所示。..., 64928, 67317, 68748, 73752]
plt.bar(ages_x,dev_y,label='开发者年龄与薪资')
plt.xlabel('年龄')
plt.ylabel('薪资...')
plt.xticks(ages_x)
plt.show()
设置字体为楷体,不加设置字体这行代码,会出现中文加载不出来的情况,如下图所示:
加了那行代码之后,运行结果如下图所示:
顺利地解决了粉丝的问题