【问题标题】:matplotlib_venn: Unable to plot venn graph for some valuesmatplotlib_venn:无法为某些值绘制维恩图
【发布时间】:2017-07-25 03:06:22
【问题描述】:

当我尝试使用包 matplotlib_venn 绘制维恩图时遇到了一些困难。

详情:

  • 如果我使用数据 [13, 12, 73, 3, 3, 1, 12],可以按预期生成图形
  • 如果我使用数据[13487, 12029, 7314, 336, 371, 17, 12611],则无法生成图表。

我该怎么办?

提前致谢!

代码:

import matplotlib.pyplot as plt
from matplotlib_venn import venn3, venn3_circles

weights = [13, 12, 73, 3, 3, 1, 12] # these weights work
# weights = [13487, 12029,  7314,   336,   371,    17, 12611] # these weights do not work
labels  = ['100', '010', '110', '001', '101', '011', '111']

fig, axis = plt.subplots(1, 1)
v = venn3(subsets=weights, ax=axis)
for label, weight in zip(labels, weights):
    v.get_label_by_id(label).set_text(str(weight))
fig.show()

【问题讨论】:

  • 这可能是一个错误,如果您将 336 更改为大于 365 的数字,它可以工作。当您 get_label_by_id 为 336 时,它返回 None。

标签: python matplotlib-venn


【解决方案1】:

也许这个维恩图不存在,因为标签'111'对应的权重大于标签'110'对应的权重。 将 12611 更改为较小的即可。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多