matplotlib添加数字标识

import matplotlib.pyplot as plt
x = [0,1,2,3,4,5,6]
y = [0.2,0.58,0.98,0.55,0.23,0.93,0.88]
fig , ax = plt.subplots(figsize=(12,8))
ax.plot(x,y,'o-',markersize=58)
ax.set_ylim(0.1,1.1)
for size in ax.get_xticklabels():
    size.set_fontname('Times New Roman')
    size.set_fontsize(23)
for size in ax.get_yticklabels():
    size.set_fontname('Times New Roman')
    size.set_fontsize(23)
for a,b in zip(x,y):
    plt.text(a,b-0.03,b,ha='center',va='bottom',fontsize=23)  

plt.text是可以在figure中添加文字,其中获取对应的横纵坐标后添加数字就可以添加对应的数字标识

matplotlib添加数字标识_第1张图片

你可能感兴趣的:(python,matplotlib)