堆叠柱状图可以很好地不雅察不合变量的分类。在图3的堆叠柱状图中,我们比较了天天的办事器负载。经由过程色彩编码后的客栈图,我们可以很轻易地看到和懂得哪些办事器天天工作最多,以及与其他办事器进行比较负载情况若何。此代码的代码与分组的条形图雷同。我们轮回遍历每一组,但此次我们把新柱放在旧柱上,而不是放在它们的旁边。
- def barplot(x_data, y_data, error_data, x_label="", y_label="", title=""):
- _, ax = plt.subplots()
- # Draw bars, position them in the center of the tick mark on the x-axis
- ax.bar(x_data, y_data, color = '#539caf', align = 'center')
- # Draw error bars to show standard deviation, set ls to 'none'
- # to remove line between points
- ax.errorbar(x_data, y_data, yerr = error_data, color = '#297083', ls = 'none', lw = 2, capthick = 2)
- ax.set_ylabel(y_label)
- ax.set_xlabel(x_label)
- ax.set_title(title)
- def stackedbarplot(x_data, y_data_list, colors, y_data_names="", x_label="", y_label="", title=""):
- _, ax = plt.subplots()
- # Draw bars, one category at a time
- for i in range(0, len(y_data_list)):
- if i == 0:
- ax.bar(x_data, y_data_list[i], color = colors[i], align = 'center', label = y_data_names[i])
- else:
推荐阅读
HTTPS那些协议:TLS, SSL, SNI, ALPN, NPN
沙龙晃荡 | 3月31日 京东、微博、华为拭魅战专家与你合营商量容器技巧实践! 本文存眷个中 Web 办事(HTTPS)相干>>>详细阅读
地址:http://www.17bianji.com/lsqh/40891.html
1/2 1