【发布时间】:2021-06-07 06:04:47
【问题描述】:
我显然做错了,因为我使用 python3 matplotlib 收到警告 - 用户警告:FixedFormatter 只能与 FixedLocator 一起使用 ax.set_xticklabels(标签)
此外,绘图标签未正确绘制,似乎重叠或损坏。 基本上,我希望每个点都代表标签 -
Total_Ticks Time_in_secs 迭代/秒 迭代
但是,它并没有显示出来。出了什么问题,我在这里遗漏了什么?
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.ticker import MaxNLocator
from matplotlib import ticker
data = [[1.0, 1.0, 1.0, 1.0], [1.0909675345548056, 1.0909675345548056, 2.499866074843752, 2.727272727272727], [1.255062680810029, 1.255062680810029, 4.346034298168655, 5.454545454545454]
print(data)
X = np.arange(4)
fig = plt.figure()
ax = fig.add_axes([0,0,1,1])
labels = ['Total_Ticks', 'Time_in_secs', 'Iterations/sec', 'Iterations']
ax.bar(X + 0.00, data[0], color = 'b', width = 0.25)
ax.bar(X + 0.25, data[1], color = 'g', width = 0.25)
ax.bar(X + 0.50, data[2], color = 'r', width = 0.25)
# save the figure
ax.legend(labels=['intel', 'amd','apple'])
ax.set_xticklabels(labels)
plt.savefig('plot.png', dpi=300, bbox_inches='tight')
【问题讨论】:
标签: python python-3.x matplotlib