Matplot lib y值乱序(因为yticks打印实际值)。如何仅打印指示性比例尺?

时间:2019-06-06 12:10:52

标签: python matplotlib

我正在尝试针对机器学习模型的迭代(x轴)绘制一条F1分数线(y轴)。 F1分数为300,范围为0-100。为了避免用300个重叠值完全填充轴,我尝试了yticks,但这会打印该迭代时的实际值,这使得y轴特别令人困惑,因为这些值不会随迭代线性上升。

如何将y轴设置为0、10、20 ... 100?我已经使用Google搜索了几个小时,感觉我不知道要使用正确的搜索字词,因为我很惊讶自己没有找到解决方法。

这是我的代码:

plt.plot(dev_history.global_step, dev_history.performance_measure, label='dev_history')
plt.xticks(np.arange(0, len(dev_history.global_step), len(dev_history.global_step) / 5))
plt.yticks(np.arange(0, len(dev_history.performance_measure), len(dev_history.performance_measure)/5))
plt.legend()
plt.show()

dev_history.global_step的值可以通过以下方式重现: np.arange(100,30001,100)

dev_history.performance_measure的值(抱歉,复制粘贴这么长)是

['27.36', '46.58', '46.64', '55.54', '61.77', '64.38', '66.85', '67.92', '70.00', '71.78', '72.45', '73.24', '73.78', '74.23', '73.99', '74.74', '75.03', '75.33', '75.56', '75.80', '75.94', '75.45', '76.02', '75.21', '76.20', '76.09', '76.32', '76.18', '76.38', '75.97', '76.25', '75.99', '75.55', '75.31', '75.85', '75.38', '75.15', '75.69', '75.73', '75.77', '75.94', '76.02', '76.02', '75.93', '76.04', '75.51', '75.88', '75.82', '75.98', '75.64', '75.12', '75.27', '75.02', '74.70', '75.63', '75.78', '75.06', '75.70', '76.02', '76.09', '74.82', '75.11', '75.12', '75.70', '75.95', '75.23', '75.91', '75.85', '75.33', '75.74', '74.81', '74.71', '74.06', '74.20', '73.53', '72.72', '74.04', '74.42', '73.18', '74.25', '75.54', '75.99', '75.54', '76.11', '75.48', '75.72', '75.68', '76.23', '74.21', '75.25', '75.74', '74.29', '74.25', '74.89', '75.57', '75.50', '75.58', '75.27', '74.02', '73.72', '74.00', '73.72', '73.85', '73.67', '73.74', '74.89', '73.72', '74.26', '74.07', '74.09', '75.74', '75.44', '75.65', '74.88', '75.62', '75.66', '75.41', '75.65', '75.29', '76.05', '75.10', '74.17', '74.34', '74.54', '74.55', '75.87', '76.19', '76.09', '75.66', '75.55', '74.56', '75.78', '74.86', '75.95', '74.83', '75.07', '74.58', '74.97', '74.88', '76.03', '76.41', '75.97', '75.93', '76.14', '75.93', '76.41', '76.28', '76.35', '76.57', '76.45', '76.20', '75.96', '74.92', '74.95', '74.52', '74.37', '74.71', '75.12', '74.46', '74.68', '74.33', '74.94', '74.82', '75.14', '75.40', '76.57', '75.90', '75.46', '75.40', '74.88', '74.96', '75.25', '76.55', '76.54', '76.27', '76.18', '75.75', '74.82', '75.19', '74.92', '75.44', '75.51', '74.41', '74.32', '75.48', '75.74', '75.13', '75.06', '75.21', '75.67', '75.27', '75.59', '75.51', '74.69', '75.51', '75.59', '75.69', '75.46', '74.58', '74.55', '74.36', '74.47', '74.58', '74.27', '74.59', '74.39', '74.46', '74.40', '74.24', '74.47', '74.37', '74.31', '75.44', '74.41', '74.40', '74.11', '74.15', '74.63', '74.65', '75.16', '75.16', '75.04', '75.52', '75.71', '75.56', '75.84', '75.01', '75.18', '75.60', '75.16', '75.50', '76.05', '75.62', '75.94', '75.97', '76.11', '75.97', '75.97', '75.91', '76.01', '76.06', '75.87', '76.03', '75.88', '75.82', '75.92', '75.32', '75.72', '74.97', '75.12', '75.25', '74.90', '74.52', '74.63', '74.74', '74.53', '75.41', '75.37', '75.59', '75.48', '75.80', '75.37', '75.23', '75.21', '75.14', '74.86', '75.10', '75.45', '75.01', '74.71', '74.56', '74.70', '74.67', '74.55', '74.58', '74.61', '74.82', '74.71', '74.82', '74.92', '74.98', '74.54', '74.93', '74.43', '74.83', '74.71', '74.76', '74.84', '75.43', '75.59', '75.01', '75.93', '76.02', '75.73', '75.83', '75.44', '75.36', '75.08', '75.78', '75.97']

0 个答案:

没有答案