# For each category after the first, the bottom of the # bar will be the top of the last category ax.bar(x_data, y_data_list[i], color = colors[i], bottom = y_data_list[i - 1], align = 'center', label = y_data_names[i]) ax.set_ylabel(y_label) ax.set_xlabel(x_label) ax.set_title(title) ax.legend(loc = 'upper right') def groupedbarplot(x_data, y_data_list, colors, y_data_names="", x_label="", y_label="", title=""): _, ax = plt.subplots() # Total width for all bars at one x location total_width = 0.8 # Width of each individual bar ind_width = total_width / len(y_data_list) # This centers each cluster of bars about the x tick mark alteration = np.arange(-(total_width/2), total_width/2, ind_width) # Draw bars, one category at a time for i in range(0, len(y_data_list)): # Move the bar to the right on the x-axis so it doesn't # overlap with previously drawn ones ax.bar(x_data + alteration[i], y_data_list[i], color = colors[i], label = y_data_names[i], width = ind_width) ax.set_ylabel(y_label) ax.set_xlabel(x_label)
推荐阅读
HTTPS那些协议:TLS, SSL, SNI, ALPN, NPN
沙龙晃荡 | 3月31日 京东、微博、华为拭魅战专家与你合营商量容器技巧实践!
本文存眷个中 Web 办事(HTTPS)相干>>>详细阅读
本文标题:5使用Python代码轻松实现数据可视化的方法
地址:http://www.17bianji.com/lsqh/40891.html
1/2 1