问题描述
绘图代码如下:
import matplotlib.pyplot as plt
def plot_time_complexity():
temp_name_list = ['ave', 'max', 'min', 'vir', 'bia']
temp_mill_time = [[676, 680, 443, 448,302],
[75602, 76788, 39313, 6289, 3250],
[6588, 6680, 3849, 3122, 1915],
[6205, 6229, 3462, 2948, 1830],
[5406, 5315, 3077, 2674, 1650]]
plt.subplot(151)
plt.bar(range(len(temp_mill_time[0])), temp_mill_time[0], color='ycrgb', tick_label=temp_name_list)
plt.ylabel('Experiment time (ms)')
plt.xlabel('MUSK1')
plt.subplot(152)
plt.bar(range(len(temp_mill_time[1])), temp_mill_time[1], color='ycrgb', tick_label=temp_name_list)
plt.xlabel('MUSK2')
plt.subplot(153)
plt.bar(range(len(temp_mill_time[2])), temp_mill_time[2], color='ycrgb', tick_label=temp_name_list)
plt.xlabel('elephant')
plt.subplot(154)
plt.bar(range(len(temp_mill_time[3])), temp_mill_time[3], color='ycrgb', tick_label=temp_name_list)
plt.xlabel('fox')
plt.subplot(155)
plt.bar(range(len(temp_mill_time[4])), temp_mill_time[4], color='ycrgb', tick_label=temp_name_list)
plt.xlabel('tiger')
plt.show()
if __name__ == "__main__":
plot_time_complexity()
绘制结果如下:
保存为.eps和.pdf时出现如下错误,但是保存为.png或者.svg时不会出错,原因未知:
解决方法
使用Visio打开.svg图像,如下,另存为.pdf等之后,便可在LaTeX中使用: