【发布时间】:2017-05-10 07:25:46
【问题描述】:
我绘制了一个带有大量水平条的水平条形图。 有什么办法可以防止 y 轴标题和条形图中的条形重叠。或者唯一的方法是增加图形的高度? 我试过使用: plt.figure(figsize=(13,14)) 但是当我尝试将 plt.show() 替换为 plt.figure( figsize=(13,14)).show()
我得到错误: 用户警告:matplotlib 当前使用的是非 GUI 后端,因此无法显示图形 "matplotlib 当前使用的是非 GUI 后端,"
import matplotlib.pyplot as plt
plt.rcdefaults()
import numpy as np
import matplotlib.pyplot as plt
length=[477, 531, 568, 651, 1599, 1605, 1635, 1960, 2009, 2446, 2668, 3308, 3433, 3889, 4180, 4529, 5388, 6378, 7588, 7671, 7679, 8505, 8763, 8863, 8910, 9028, 9030, 10124, 10722, 10894, 11103, 11388, 12167, 12464, 14217, 14367, 14472, 16501, 18765, 19407, 19627, 20795, 21727, 21912, 22620, 24871, 25045, 25625, 25867, 27512, 30380, 30424, 31264, 32070, 32277, 33879, 35749, 35932, 37406, 37414, 40040, 42070, 42516, 42804, 44381, 46314, 48216, 48349, 50547, 50796, 53759, 54716, 65888, 81106, 86280, 104522, 179133, 189921]
y_pos = np.arange(len(length))
error = np.random.rand(len(length))
plt.barh(y_pos, length, xerr=error*2, align='center', alpha=0.3)
plt.yticks(y_pos, length)
plt.xlabel('Lengths')
plt.title('Comparison of different cuts')
plt.show()
这是我指的图表:
【问题讨论】:
-
我设法用这个答案做到了这一点:stackoverflow.com/questions/35127920/…
标签: python matplotlib plot graph