柱状图
import matplotlib.pyplot as plt
from matplotlib.pyplot import MultipleLocator
import matplotlib as mpl
import numpy as np
mpl.rcParams["font.sans-serif"] = ["SimHei"]
mpl.rcParams["axes.unicode_minus"] = False
y = [92.5, 95.0, 91.0, 93.5, 95.0, 94.0, 94.0, 94.5]
y1 = [7.92, 5.0, 9.0, 6.93, 5.0, 6.0, 5.1, 5.94]
x = np.arange(8)
def autolabel(rects):
for rect in rects:
height = rect.get_height()
plt.text(rect.get_x() + rect.get_width() / 2. - 0.2, 1.03 * height, '%s' % float(height))
bar_width = 0.35
failure_label = ["A", "B", "C", "D", "E", "F", "G", "H"]
a = plt.bar(x, y, bar_width, align="center", color="c", label="准确率", alpha=0.5)
b = plt.bar(x + bar_width, y1, bar_width, color="red", align="center", label="误报率", alpha=0.5)
autolabel(a)
autolabel(b)
plt.xlabel("Failure Items")
plt.ylabel("Percent(%)")
plt.title("Failures Detection Evaluation", fontsize=10)
plt.xticks(x + bar_width / 2, failure_label)
y_major_locator = MultipleLocator(5)
plt.gca().yaxis.set_major_locator(y_major_locator)
plt.legend(loc='center right')
plt.show()
import matplotlib.pyplot as plt
import matplotlib as mpl
import numpy as np
mpl.rcParams["font.sans-serif"] = ["SimHei"]
mpl.rcParams["axes.unicode_minus"] = False
TF = [94, 95, 92, 94, 97, 94, 94, 96]
WN = [6, 5, 8, 6, 3, 6, 6, 4]
TN = [94, 96, 91, 94, 96, 95, 96, 96]
WF = [6, 4, 9, 6, 4, 5, 4, 4]
failure_label = ["A", "B", "C", "D", "E", "F", "G", "H"]
x = np.arange(8)
bar_width = 0.35
fig, ax = plt.subplots(figsize=(10, 7))
ax.bar(x, TF, bar_width, align="center", color="blue", label="真异常", alpha=0.5)
ax.bar(x, WN, bar_width, color="red", bottom=TF, align="center", label="假正常", alpha=0.5)
ax.bar(x+bar_width, TN, bar_width, align="center", color="green", label="真正常", alpha=0.5)
ax.bar(x+bar_width, WF, bar_width, color="brown", bottom=TN, align="center", label="假异常", alpha=0.5)
ax.set_title("Failures Detection Evaluation", fontsize=15)
ax.set_xlabel("Failure Items")
ax.set_ylabel("Data Items")
ax.set_xticks(x + bar_width / 2)
ax.set_xticklabels(failure_label)
ax.legend(loc='center right')
plt.show()
折线图
import matplotlib.pyplot as plt
import matplotlib as mpl
mpl.rcParams["font.sans-serif"] = ["SimHei"]
mpl.rcParams["axes.unicode_minus"] = False
plt.xlabel("Video Items")
plt.ylabel("Frequency")
x_data = ['fv', 'nv', 'mv']
y_data = [9, 11, 15]
y_data2 = [9, 38, 18]
ln1, = plt.plot(x_data, y_data, color='red', linewidth=2.0, linestyle='--')
ln2, = plt.plot(x_data, y_data2, color='blue', linewidth=3.0, linestyle='-.')
plt.legend(handles=[ln1, ln2], labels=['FADA', 'noFADA'])
ax = plt.gca()
ax.spines['right'].set_color('none')
ax.spines['top'].set_color('none')
plt.show()
import matplotlib as mpl
import matplotlib.pyplot as plt
mpl.rcParams["font.sans-serif"] = ["SimHei"]
mpl.rcParams["axes.unicode_minus"] = False
x = ['A', 'B', 'C', 'D', 'E', 'F']
y = [96, 98, 97, 98, 95, 96]
y2 = [94, 97, 95, 97, 96, 95]
plt.figure(figsize=(7, 4))
ln1, = plt.plot(x, y, 'b', lw=1.5)
ln2, = plt.plot(x, y2, 'g', lw=1.5)
plt.legend(handles=[ln1, ln2], labels=['oldVQA', 'newVQA'])
plt.plot(y, 'ro')
plt.plot(y2, 'ro')
plt.grid(True)
plt.axis('tight')
plt.xlabel('Failure Items')
plt.ylabel('Percent(%)')
plt.title('准确率')
plt.show()
热力图
import matplotlib.pyplot as plt
import seaborn as sns
sns.set()
x = [[0.756, 0.67, 0.59], [0.66, 0.63, 0.72], [0.73, 0.69, 0.57]]
ax = sns.heatmap(x, annot=True, vmax=1, vmin=0)
ax.set_title("Memory Utilization After Scheduler")
b = ax.get_figure()
plt.show()