konstantint / matplotlib-venn

Area-weighted venn-diagrams for Python/matplotlib
MIT License
520 stars 68 forks source link

Subplot problems #55

Closed shinokada closed 4 years ago

shinokada commented 4 years ago

I am trying to plot 1 row 2 columns. All good except the image size.

How can I make the images bigger? How to set the image height and width?

# A
from matplotlib_venn import venn2, venn2_circles
from matplotlib import pyplot as plt
%matplotlib inline

figure, (ax1, ax2) = plt.subplots(1, 2)

v1 = venn2(subsets=(3, 3, 1), ax=ax1)
c1 = venn2_circles(subsets=(3, 3, 1), ax=ax1)

for area in ['01', '10', '11']:
    color = 'magenta' if area != '01' else 'white'
    v1.get_patch_by_id(area).set_color(color)
    v1.get_patch_by_id(area).set_alpha(1)
    txt = v1.get_label_by_id(area)
    if txt: txt.set_text('')

ax1.set_axis_on()
ax1.set_facecolor('white')
ax1.set(title='A')
ymin, ymax = ax1.get_ylim()
ax1.set_ylim(ymin - 0.1, ymax)

# B
v2 = venn2(subsets=(3, 3, 1), ax=ax2)
c2 = venn2_circles(subsets=(3, 3, 1), ax=ax2)

for area in ['01', '10', '11']:
    color = 'magenta' if area != '01' else 'white'
    v1.get_patch_by_id(area).set_color(color)
    v1.get_patch_by_id(area).set_alpha(1)
    txt = v1.get_label_by_id(area)
    if txt: txt.set_text('')

for area in ['01', '10', '11']:
    color = 'magenta' if area != '10' else 'white'
    v2.get_patch_by_id(area).set_color(color)
    v2.get_patch_by_id(area).set_alpha(1)
    txt = v2.get_label_by_id(area)
    if txt: txt.set_text('')

ax2.set_axis_on()
ax2.set_facecolor('white')
ax2.set(title='B')
ymin, ymax = ax2.get_ylim()
ax2.set_ylim(ymin - 0.1, ymax)

plt.show()

This shows the following.

image

shinokada commented 4 years ago

I needed to set the figsize.

figure, (ax1, ax2) = plt.subplots(1, 2,figsize=(15,15))

Thank you for your work.