我正在绘制一条Precision/Recall Curve,并想为绘图中的每个标记放置特定的标签。
下面是生成绘图的代码:
from matplotlib import pyplot
pyplot.plot([0, 100], [94, 100], linestyle='--')
pyplot.xlabel("Recall")
pyplot.ylabel("Precision")
list_of_rec = [
99.96,99.96,99.96,99.96,99.96,99.96,99.8,98.25,96.59,93.37,83.74,63.53,48.72,25.05,10.7,4.27,0.73,0.23]
list_of_prec = [
94.12,94.12,94.12,94.12,94.12,94.12,94.42,95.14,95.92,96.57,97.33,98.26,98.72,99.0,99.0,99.17,99.75,99.19]
list_of_markers = [
0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 5.5, 6.0, 6.5, 7.0, 7.5, 8.0, 8.5
]
# plot the precision-recall curve for the model
pyplot.plot(list_of_rec, list_of_prec, marker='*', markersize=8)
pyplot.show()这给我提供了以下图:

对于图(*)中的每个标记,我想用list_of_markers中的文本标记它们。似乎找不到一个选项来将文本标签列表传递到绘图的任何地方,任何帮助。
发布于 2019-05-15 18:37:52
您可以通过循环遍历每个标记并将标注放置为文本注记来对每个标记进行注记
for x, y, text in zip(list_of_rec, list_of_prec, list_of_markers):
plt.text(x, y, text)

https://stackoverflow.com/questions/56147039
复制相似问题