首页 > 解决方案 > matplotlib 堆积条形图在版本更新后被窃听

问题描述

使用以下代码:

 for index,axis in enumerate(axes):
            for counter, bar in enumerate(axis):
                max_height = start_extra_heights[counter]
                w, h = bar.get_width(), bar.get_height()
                if 0.0 < h < need_arrow:
                    plt.annotate(value_format.format(h)+'%', xy=(bar.get_x(), bar.get_y()),
                                 xytext=(bar.get_x() + 0.2, max_height + jumps[counter]), color=suit_colors_dict[index],
                                 arrowprops=dict(arrowstyle="->"))
                    jumps[counter] += proportion_to_high * 1.2
                elif h > 0.0:
                    plt.text(bar.get_x() + w / 2, bar.get_y() + h / 2, value_format.format(h)+'%', ha="center",
                             va="center")
        # adding the number of total lines of the original pileups
        for index, bar in enumerate(axes[-1]):
            max_height = start_extra_heights[index]
            if max_height == 0.0:
                max_height = 1.3
            plt.annotate(value_format.format(sum_column[index]), xy=(bar.get_x(), bar.get_y()+bar.get_height()),
                         xytext=(bar.get_x(), max_height + jumps[index]),
                         arrowprops=dict(arrowstyle='fancy'))

    return plt, axes

我能够生成这样的图: 在此处输入图像描述

在不同的python环境(conda)上,我正在执行命令(来自执行图表脚本的不同用户)

pip install matplotlib –user

从那时起,绘图并不总是被创建(tiff 文件未创建或创建但为空),如果这样做,颜色将被合并(例如,参见“rep”列的橙色和粉红色)并且文本相互重叠(如“norep”列,棕色和紫色)​​: 在此处输入图像描述

我尝试从同一用户卸载 matplotlib 包并重新安装我认为以前存在的不同版本,但错误的图表仍然存在。

任何想法如何解决这一问题?

标签: pythonmatplotlibanaconda

解决方案


推荐阅读