python pyplot注释
我目前正在使用以下代码使用python pyplot绘制图形:python pyplot注释,python,marker,matplotlib,Python,Marker,Matplotlib,我目前正在使用以下代码使用python pyplot绘制图形: plt.plot([row[2] for row in data],[row[1] for row in data], type, marker='o', label=name) 但是,我希望点处的标记是行[1]中的数据,而不是'o'的默认标记 有人能解释一下怎么做吗?那么您想注释直线上点的y值 对每个点使用注释。例如: import matplotlib.pyplot as plt x = range(10) y =
plt.plot([row[2] for row in data],[row[1] for row in data], type, marker='o', label=name)
但是,我希望点处的标记是行[1]中的数据,而不是'o'
的默认标记
有人能解释一下怎么做吗?那么您想注释直线上点的y值
对每个点使用注释
。例如:
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()