4
我目前使用下面的代码使用Python pyplot绘制图表:蟒蛇pyplot注释
plt.plot([row[2] for row in data],[row[1] for row in data], type, marker='o', label=name)
然而,代替'o'
默认标记我想在点标记是在row[1]
数据
有人可以解释如何做到这一点?
我目前使用下面的代码使用Python pyplot绘制图表:蟒蛇pyplot注释
plt.plot([row[2] for row in data],[row[1] for row in data], type, marker='o', label=name)
然而,代替'o'
默认标记我想在点标记是在row[1]
数据
有人可以解释如何做到这一点?
所以你想注释你的线沿点的y值?每个点使用annotate
。例如:
import matplotlib.pyplot as plt
x = range(10)
y = range(10)
fig, ax = plt.subplots()
# Plot the line connecting the points
ax.plot(x, y)
# At each point, plot the y-value with a white box behind it
for xpoint, ypoint in zip(x, y):
ax.annotate('{:.2f}'.format(ypoint), (xpoint,ypoint), ha='center',
va='center', bbox=dict(fc='white', ec='none'))
# Manually tweak the limits so that our labels are inside the axes...
ax.axis([min(x) - 1, max(x) + 1, min(y) - 1, max(y) + 1])
plt.show()