konstantint / matplotlib-venn

Area-weighted venn-diagrams for Python/matplotlib
MIT License
496 stars 67 forks source link

Change font style and size #2

Closed gabyrech closed 11 years ago

gabyrech commented 11 years ago

HI!, Thank you very much for the package! It is very useful and easy to use! I just wondering if there is some way to change the font style and font size for the numbers inside the circles. Thank you very much! Regards Gabriel

konstantint commented 11 years ago

Hello, you have at least two ways here. Firstly, you can change the global default font for all of matplotlib before creating the venn plot:

font = {'family' : 'sans',
        'weight' : 'bold',
        'size'   : 22}
matplotlib.rc('font', **font)

If you want a more fine-grained control, you have access to all the labels of a matplotlib-venn plot as Text elements using the get_label_by_id function. You are rather free to do what you want with them, including changing properties, text, or moving around.

d = matplotlib_venn.venn2((1,2,3))
label = d.get_label_by_id('11')          # Those are subset labels (i.e. numbers)
label.set_fontsize(22) 
label.set_family('serif')
label.set_x(label.get_position()[0] + 0.1)

d.get_label_by_id('A').set_text('$x^2$') # Those are set labels
d.get_label_by_id('A').set_fontsize(22)
gabyrech commented 11 years ago

Thanks!