Matplotlib中未显示标签

时间:2019-03-11 17:01:57

标签: python matplotlib

我正在将点绘制到图形上。三行。我想给每行加上标签。我正在这样做,如下所示:

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
x_axis = np.array([1, 3, 5, 7, 9])
y_axis1 = np.array([173.825, 139.386, 129.364, 123.281, 119.162])
e1 = np.array([1.895, 1.599, 1.551, 1.783, 1.272])

y_axis2 = np.array([161.168, 143.071, 135.891, 131.081, 126.970])
e2 = np.array([2.076, 1.700, 1.400, 1.295, 0.788])

y_axis3 = np.array([208.306, 198.804, 193.063, 189.554, 185.764])
e3 = np.array([1.314, 1.350, 1.046, 1.770, 1.135])

plt.axis([0, 11, 110, 210])
plt.errorbar(x_axis, y_axis1, e1, linestyle='solid', marker='.', ecolor='red', color='blue', label='Line1')
plt.errorbar(x_axis, y_axis2, e2, linestyle='solid', marker='.', ecolor='red', color='green', label='Line2')
plt.errorbar(x_axis, y_axis3, e3, linestyle='solid', marker='.', ecolor='red', color='yellow', label='Line3')
plt.xlabel('Data')
plt.ylabel('Average')

plt.show()

但是标签未显示。输出如下:

enter image description here

0 个答案:

没有答案