如何在pyplot图的水平线之间放置标签?

时间:2019-05-02 02:24:55

标签: python matplotlib

我使用此代码生成图。

import matplotlib.pyplot as plt
import numpy as np

fig, ax = plt.subplots()

x = np.array([0,1,2,3])
y = np.array([0,0.7, 1.4, 2.1])
my_xticks = ['a', 'b', 'c', 'd']
plt.xticks(x, my_xticks)
plt.yticks(np.arange(y.min(), y.max(), 0.7))
plt.plot(x, y)

for i in range(0,5):
    plt.hlines(i*(2.1/5),0,4,color='b')
plt.show()

获得以下情节。

enter image description here

但是我想在水平线之间添加间隔标签。 enter image description here 如何在水平线之间的间隔组中添加此类标签?

0 个答案:

没有答案