Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to modify the font size in matplotlib-venn

I have the following Venn diagrams:

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'))

That looks like this:

enter image description here

How can I control the font size of the plot? I'd like to increase it.

like image 651
neversaint Avatar asked Apr 03 '15 04:04

neversaint


People also ask

How do I change text size in Matplotlib?

Plot x data points using plot() method. To change the font size of the scale in matplotlib, we can use labelsize in the ticks_params()method. To display the figure, use show() method.

How do you increase font size in Python?

Open the Python shell. Then, in the menu bar, under "Python" (directly to the right of the Apple icon), you will find "Preferences". Under this, you will find the "Font/Tabs" option, and you can change the font size according to your preference.


1 Answers

If out is the object returned by venn3(), the text objects are just stored as out.set_labels and out.subset_labels, so you can do:

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)
like image 128
Marius Avatar answered Oct 12 '22 12:10

Marius