我有以下Venn图:
from matplotlib import pyplot as plt
from matplotlib_venn import venn3, venn3_circles
set1 = set(['A', 'B', 'C', 'D'])
set2 = set(['B', 'C', 'D', 'E'])
set3 = set(['C', 'D',' E', 'F', 'G'])
venn3([set1, set2, set3], ('Set1', 'Set2', 'Set3'))看起来是这样的:

如何控制情节的字体大小?我想加一点。
发布于 2015-04-03 04:34:25
如果out是venn3()返回的对象,则文本对象仅存储为out.set_labels和out.subset_labels,因此可以这样做:
from matplotlib import pyplot as plt
from matplotlib_venn import venn3, venn3_circles
set1 = set(['A', 'B', 'C', 'D'])
set2 = set(['B', 'C', 'D', 'E'])
set3 = set(['C', 'D',' E', 'F', 'G'])
out = venn3([set1, set2, set3], ('Set1', 'Set2', 'Set3'))
for text in out.set_labels:
text.set_fontsize(14)
for text in out.subset_labels:
text.set_fontsize(16)发布于 2020-07-08 09:23:32
在我的例子中,out.subset_labels的一些值是NoneType。为了省去这个问题,我做了:
from matplotlib import pyplot as plt
from matplotlib_venn import venn3, venn3_circles
set1 = set(['A', 'B', 'C', 'D'])
set2 = set(['B', 'C', 'D', 'E'])
set3 = set(['C', 'D',' E', 'F', 'G'])
out = venn3([set1, set2, set3], ('Set1', 'Set2', 'Set3'))
for text in out.set_labels:
text.set_fontsize(15)
for x in range(len(out.subset_labels)):
if out.subset_labels[x] is not None:
out.subset_labels[x].set_fontsize(15)发布于 2021-12-05 05:29:56
我只是在Matplotlib中更改了字体大小(还可以使用rcParams更改文本颜色)。
from matplotlib_venn import venn3
from matplotlib import pyplot as plt
plt.figure(figsize = (6, 5))
font1 = {'family':'serif','color':'black','size':16} # use for title
font2 = {'family': 'Comic Sans MS', 'size': 8.5} # use for labels
plt.rc('font', **font2) # sets the default font
plt.rcParams['text.color'] = 'darkred' # changes default text colour
venn3(subsets=({'A', 'B', 'C', 'D', 'X', 'Y', 'Z'},
{'A', 'B', 'E', 'F', 'P'}, {'B', 'C', 'E', 'G'}),
set_labels=('Set1', 'Set2', 'Set3'),
set_colors=("coral", "skyblue", "lightgreen"), alpha=0.9)
plt.title("Changing Font Size in Matplotlib_venn Diagrams", fontdict=font1)
plt.show()https://stackoverflow.com/questions/29426075
复制相似问题