Contraceptive methods
| Category | Examples |
|---|---|
| Permanent | Tubal sterilization, Vasectomy |
| Long-Acting Reversible (LARC) | IUD (copper, levonorgestrel), Subdermal implant |
| Short-Acting Hormonal | Combined oral contraceptives, Progestin-only pills, Patch, Vaginal ring, Injectable |
| Barrier | Male/female condom, Diaphragm, Cervical cap, Spermicide |
| Behavioral/Natural | Lactational amenorrhea, Fertility awareness, Withdrawal |
| Emergency | Copper IUD, Ulipristal acetate, Levonorgestrel, Combined hormonal pills |

| Method | Theoretical Effectiveness (%) | Actual Effectiveness (%) | Use at 1 Year (%) |
|---|---|---|---|
| No method | 85 | 85 | - |
| Fertility awareness | 96 | 76 | 47 |
| Withdrawal | 96 | 78 | 46 |
| Condom (male) | 98 | 82 | 43 |
| Diaphragm | 94 | 82 | 57 |
| Spermicides | 82 | 72 | 43 |
| Female sterilization | 99.5 | ~99.5 | - |
| IUD (copper) | >99 | >99 | High |
| Implant (etonogestrel) | >99.9 | >99.9 | High |
| Injectable (DMPA) | 99.7 | ~97 | Moderate |
| COC (pill) | 99.7 | ~91 | Moderate |
| EC Option | Mechanism | Window | Notes |
|---|---|---|---|
| Copper IUD | Prevents fertilization + implantation | Within 5 days | Most effective EC; works in obese women |
| Ulipristal acetate | Progesterone receptor antagonist; delays/inhibits ovulation | Within 5 days | Requires prescription; may be more effective than LNG near ovulation |
| Levonorgestrel (Plan B) | Delays/inhibits ovulation | Within 72 hours (up to 120 hrs) | OTC; less effective in obesity |
| Combined hormonal pills (Yuzpe) | Delays ovulation | Within 72 hours | Less effective, more nausea than LNG alone |
| Component | Common Adverse Effects |
|---|---|
| Estrogen | Breast fullness, fluid retention, headache, nausea, increased BP, VTE risk |
| Progestin | Depression, libido changes, hirsutism, acne, irregular bleeding |
| Combined (estrogen + progestin) | Rare: thromboembolism, MI, stroke - especially in women >35 who smoke |
Types in flow charts
mkdir -p /tmp/workspace/contraceptives && ls /tmp/workspace/contraceptives/
~/contraceptives/flowcharts.py
import matplotlib.pyplot as plt
import matplotlib.patches as mpatches
from matplotlib.patches import FancyBboxPatch, FancyArrowPatch
import matplotlib.patheffects as pe
# ─────────────────────────────────────────────────────────────────────────────
# Helper utilities
# ─────────────────────────────────────────────────────────────────────────────
def rounded_box(ax, x, y, w, h, text, facecolor, textcolor='white',
fontsize=9, bold=False, edgecolor='white', lw=1.2, radius=0.04):
box = FancyBboxPatch((x - w/2, y - h/2), w, h,
boxstyle=f"round,pad={radius}",
linewidth=lw, edgecolor=edgecolor,
facecolor=facecolor, zorder=3)
ax.add_patch(box)
weight = 'bold' if bold else 'normal'
ax.text(x, y, text, ha='center', va='center', fontsize=fontsize,
color=textcolor, fontweight=weight, zorder=4,
wrap=True, multialignment='center')
def arrow(ax, x1, y1, x2, y2, color='#555555', lw=1.5):
ax.annotate('', xy=(x2, y2), xytext=(x1, y1),
arrowprops=dict(arrowstyle='->', color=color,
lw=lw, connectionstyle='arc3,rad=0'))
# ─────────────────────────────────────────────────────────────────────────────
# FIGURE 1 – Master Classification Flowchart
# ─────────────────────────────────────────────────────────────────────────────
def fig1_master():
fig, ax = plt.subplots(figsize=(18, 12))
ax.set_xlim(0, 18)
ax.set_ylim(0, 12)
ax.axis('off')
ax.set_facecolor('#F7F9FC')
fig.patch.set_facecolor('#F7F9FC')
ax.text(9, 11.5, 'CONTRACEPTIVE METHODS – Master Classification',
ha='center', va='center', fontsize=14, fontweight='bold', color='#1a1a2e')
# Root node
rounded_box(ax, 9, 10.6, 3.2, 0.7, 'CONTRACEPTIVE METHODS',
'#1a1a2e', fontsize=11, bold=True)
# Level 1 branches (x positions)
L1 = [
(1.5, 8.8, '#c0392b', 'PERMANENT'),
(4.5, 8.8, '#8e44ad', 'LONG-ACTING\nREVERSIBLE (LARC)'),
(8.0, 8.8, '#2471a3', 'SHORT-ACTING\nHORMONAL'),
(12.5, 8.8, '#117a65', 'BARRIER'),
(15.5, 8.8, '#d4800a', 'BEHAVIORAL /\nNATURAL'),
]
for (x, y, col, lbl) in L1:
arrow(ax, 9, 10.2, x, 9.15, color='#aaaaaa')
rounded_box(ax, x, y, 2.6, 0.75, lbl, col, fontsize=9, bold=True)
# ── PERMANENT children ──
perm = [
(0.9, 7.5, 'Vasectomy\n(male)'),
(2.1, 7.5, 'Tubal\nSterilization'),
]
for (x, y, lbl) in perm:
arrow(ax, 1.5, 8.42, x, 7.75)
rounded_box(ax, x, y, 1.0, 0.55, lbl, '#e74c3c', fontsize=7.5)
# ── LARC children ──
larc = [
(3.4, 7.5, 'Copper\nIUD\n(10–12 yr)'),
(4.5, 7.5, 'Levonorgestrel\nIUD\n(3–7 yr)'),
(5.6, 7.5, 'Etonogestrel\nImplant\n(3–5 yr)'),
]
for (x, y, lbl) in larc:
arrow(ax, 4.5, 8.42, x, 7.85)
rounded_box(ax, x, y, 1.05, 0.7, lbl, '#a569bd', fontsize=7)
# ── SHORT-ACTING HORMONAL children ──
short = [
(6.0, 7.5, 'Combined\nOral\nContraceptive'),
(7.2, 7.5, 'Progestin-\nOnly Pill\n(mini-pill)'),
(8.4, 7.5, 'Transdermal\nPatch'),
(9.6, 7.5, 'Vaginal\nRing'),
(10.8, 7.5, 'Injectable\n(DMPA)\nevery 3 mo'),
]
for (x, y, lbl) in short:
arrow(ax, 8.0, 8.42, x, 7.85)
rounded_box(ax, x, y, 1.1, 0.75, lbl, '#2e86c1', fontsize=7)
# ── BARRIER children ──
barrier = [
(11.5, 7.5, 'Male\nCondom'),
(12.5, 7.5, 'Female\nCondom'),
(13.5, 7.5, 'Diaphragm\n/ Cerv. Cap'),
(14.5, 7.5, 'Spermicide'),
]
for (x, y, lbl) in barrier:
arrow(ax, 12.5, 8.42, x, 7.75)
rounded_box(ax, x, y, 0.95, 0.55, lbl, '#148f77', fontsize=7)
# ── BEHAVIORAL children ──
behav = [
(14.8, 7.5, 'Fertility\nAwareness'),
(15.9, 7.5, 'Lactational\nAmenorrhea'),
(17.0, 7.5, 'Withdrawal'),
]
for (x, y, lbl) in behav:
arrow(ax, 15.5, 8.42, x, 7.75)
rounded_box(ax, x, y, 1.0, 0.55, lbl, '#e67e22', fontsize=7)
# ── EMERGENCY band ──
rounded_box(ax, 9, 6.5, 16.5, 0.7,
'EMERGENCY CONTRACEPTION (post-coital / after unprotected intercourse)',
'#922b21', fontsize=10, bold=True)
ec = [
(3.5, 5.5, '#c0392b', 'Copper IUD\n(within 5 days)\nMost effective'),
(7.5, 5.5, '#8e44ad', 'Ulipristal Acetate\n(within 5 days)\nPx receptor antagonist'),
(11.5, 5.5, '#2471a3', 'Levonorgestrel\n(Plan B)\nWithin 72–120 h'),
(15.2, 5.5, '#117a65', 'Combined\nHormonal Pills\n(Yuzpe method)'),
]
for (x, y, col, lbl) in ec:
arrow(ax, 9, 6.15, x, 5.85, color='#c0392b')
rounded_box(ax, x, y, 2.8, 0.75, lbl, col, fontsize=8)
# ── Failure-rate legend strip ──
ax.text(0.4, 4.6, 'Typical-use failure rate (pregnancies per 100 women/year):',
fontsize=8.5, color='#333', fontweight='bold')
items = [
('#1a1a2e', 'Implant <0.05'),
('#8e44ad', 'LNG-IUD 0.2'),
('#c0392b', 'Cu-IUD 0.8'),
('#2471a3', 'Injectable 6'),
('#117a65', 'COC/Patch/Ring 9'),
('#d4800a', 'Condom 18'),
('#e67e22', 'Withdrawal 22'),
('#922b21', 'Spermicide 28'),
]
xpos = 0.4
for col, lbl in items:
patch = mpatches.Patch(color=col, label=lbl)
ax.text(xpos, 4.1, '■', color=col, fontsize=14, va='center')
ax.text(xpos + 0.35, 4.1, lbl, fontsize=7.5, va='center', color='#333')
xpos += 2.1
plt.tight_layout()
plt.savefig('/tmp/workspace/contraceptives/fig1_master_classification.png',
dpi=180, bbox_inches='tight')
plt.close()
print('Fig 1 saved.')
# ─────────────────────────────────────────────────────────────────────────────
# FIGURE 2 – Hormonal Methods Deep-Dive Flowchart
# ─────────────────────────────────────────────────────────────────────────────
def fig2_hormonal():
fig, ax = plt.subplots(figsize=(16, 11))
ax.set_xlim(0, 16)
ax.set_ylim(0, 11)
ax.axis('off')
ax.set_facecolor('#EEF4FB')
fig.patch.set_facecolor('#EEF4FB')
ax.text(8, 10.6, 'HORMONAL CONTRACEPTIVES – Classification & Key Details',
ha='center', va='center', fontsize=13, fontweight='bold', color='#1a1a2e')
# Root
rounded_box(ax, 8, 9.8, 3.5, 0.65, 'HORMONAL CONTRACEPTIVES',
'#1a1a2e', fontsize=11, bold=True)
# Two branches
arrow(ax, 8, 9.47, 4, 8.75)
arrow(ax, 8, 9.47, 12, 8.75)
rounded_box(ax, 4, 8.45, 4.0, 0.55,
'COMBINATION\n(Estrogen + Progestin)', '#154360', fontsize=9, bold=True)
rounded_box(ax, 12, 8.45, 4.0, 0.55,
'PROGESTIN-ONLY', '#4a235a', fontsize=9, bold=True)
# ── Combination children ──
combo = [
(1.3, 7.2, 'Combined\nOral\nContraceptive\n(COC)',
'• Ethinyl estradiol\n + progestin\n• Monophasic /\n Triphasic\n• 21-24 active +\n 4-7 placebo days\n• Failure: ~9%'),
(4.1, 7.2, 'Transdermal\nPatch',
'• EE + norelgestromin\n or levonorgestrel\n• 1 patch/week × 3 wk\n• ↑ VTE risk vs COC\n• Less effective\n if wt >90 kg\n• Failure: ~9%'),
(6.9, 7.2, 'Vaginal\nRing',
'• EE + etonogestrel\n• Insert 3 wk,\n remove 1 wk\n• Failure: ~9%\n• d/c: vaginal\n irritation'),
]
for (x, y, title, detail) in combo:
arrow(ax, 4, 8.17, x, 7.65)
rounded_box(ax, x, 7.4, 1.6, 0.45, title, '#1f618d', fontsize=8, bold=True)
rounded_box(ax, x, 6.35, 1.55, 1.75, detail, '#d6eaf8', textcolor='#1a1a2e',
fontsize=7, edgecolor='#1f618d', lw=1)
# ── Progestin-only children ──
prog = [
(9.2, 7.2, 'Progestin-Only\nPill (Mini-pill)',
'• Norethindrone\n or drospirenone\n• Daily, no\n hormone-free\n interval\n• Safe in BF\n• Failure: ~9%'),
(11.5, 7.2, 'Injectable\n(DMPA)',
'• Medroxyprogesterone\n acetate\n• IM/SC q 3 months\n• Amenorrhea common\n• Fertility return\n delayed 6–9 mo\n• Bone loss risk\n• Failure: ~6%'),
(13.8, 7.2, 'Implant\n(Etonogestrel)',
'• Subdermal, inner arm\n• Duration 3–5 yr\n• As reliable as\n sterilization\n• Failure: <0.05%\n• Irregular bleeding'),
(15.5, 7.2, 'LNG-IUD',
'• Levonorgestrel\n• 3–7 yr duration\n• Reduces heavy\n menstrual bleeding\n• Avoid if PID or\n ectopic Hx\n• Failure: 0.2%'),
]
for (x, y, title, detail) in prog:
arrow(ax, 12, 8.17, x, 7.65)
rounded_box(ax, x, 7.4, 1.55, 0.45, title, '#6c3483', fontsize=8, bold=True)
rounded_box(ax, x, 6.35, 1.5, 1.75, detail, '#e8daef', textcolor='#1a1a2e',
fontsize=7, edgecolor='#6c3483', lw=1)
# ── Mechanism panel ──
ax.add_patch(FancyBboxPatch((0.3, 3.95), 15.4, 1.55,
boxstyle='round,pad=0.05', facecolor='#fdfefe',
edgecolor='#1a1a2e', lw=1.5, zorder=2))
ax.text(8, 5.35, 'MECHANISM OF ACTION', ha='center', fontsize=10,
fontweight='bold', color='#1a1a2e', zorder=3)
mech_items = [
(2.2, 4.7, '#154360', 'Estrogen\n(−) FSH → suppresses\nfollicle development'),
(6.0, 4.7, '#1f618d', 'Progestin\n(−) LH → prevents\novulation'),
(9.8, 4.7, '#117a65', 'Progestin\nThickens cervical\nmucus → ↓ sperm'),
(13.5, 4.7, '#8e44ad', 'Progestin\nDecidualized thin\nendometrium'),
]
for (x, y, col, txt) in mech_items:
rounded_box(ax, x, y, 2.8, 0.95, txt, col, fontsize=8)
# ── Contraindications panel ──
ax.add_patch(FancyBboxPatch((0.3, 0.35), 15.4, 3.45,
boxstyle='round,pad=0.05', facecolor='#fdedec',
edgecolor='#c0392b', lw=1.5, zorder=2))
ax.text(8, 3.65, 'CONTRAINDICATIONS TO ESTROGEN-CONTAINING METHODS (US MEC Cat 4)',
ha='center', fontsize=9, fontweight='bold', color='#c0392b', zorder=3)
ci_col1 = ('Category 4 (Absolute):\n'
'• Age ≥35 + smoking ≥15 cigs/day\n'
'• Known ischemic heart disease\n'
'• Acute DVT / high VTE risk\n'
'• Stroke / thrombogenic mutations\n'
'• Migraines with aura\n'
'• Breast cancer')
ci_col2 = ('• Complicated valvular heart disease\n'
'• Hypertension ≥160/100 mmHg\n'
'• SLE with +antiphospholipid Ab\n'
'• Cirrhosis / hepatic adenoma\n'
'• Diabetes with end-organ damage\n'
'• Breastfeeding <21 days postpartum\n'
'• Peripartum cardiomyopathy (<6 mo)')
ci_col3 = ('Prefer PROGESTIN-ONLY or\nNONHORMONAL methods when:\n\n'
'• Estrogen contraindicated\n'
'• Breastfeeding\n'
'• BMI ≥30 (patch CI)\n'
'• Long-term need → LARC\n'
'• Poor adherence → LARC\n'
'• STI protection needed\n → Add condom')
ax.text(2.5, 3.25, ci_col1, fontsize=7.5, color='#7b241c', va='top', zorder=3)
ax.text(7.5, 3.25, ci_col2, fontsize=7.5, color='#7b241c', va='top', zorder=3)
ax.add_patch(FancyBboxPatch((11.2, 0.55), 4.2, 2.9,
boxstyle='round,pad=0.05', facecolor='#d5f5e3',
edgecolor='#117a65', lw=1.2, zorder=3))
ax.text(13.3, 3.3, ci_col3, fontsize=7.5, color='#0e6655', va='top', zorder=4)
plt.tight_layout()
plt.savefig('/tmp/workspace/contraceptives/fig2_hormonal_deepdive.png',
dpi=180, bbox_inches='tight')
plt.close()
print('Fig 2 saved.')
# ─────────────────────────────────────────────────────────────────────────────
# FIGURE 3 – Emergency Contraception Decision Flowchart
# ─────────────────────────────────────────────────────────────────────────────
def fig3_emergency():
fig, ax = plt.subplots(figsize=(14, 10))
ax.set_xlim(0, 14)
ax.set_ylim(0, 10)
ax.axis('off')
ax.set_facecolor('#FEF9E7')
fig.patch.set_facecolor('#FEF9E7')
ax.text(7, 9.65, 'EMERGENCY CONTRACEPTION – Decision Flowchart',
ha='center', fontsize=13, fontweight='bold', color='#1a1a2e')
# Start
rounded_box(ax, 7, 8.9, 5.5, 0.65,
'Unprotected / Inadequately Protected Intercourse',
'#922b21', fontsize=10, bold=True)
# Q1
arrow(ax, 7, 8.57, 7, 8.0)
rounded_box(ax, 7, 7.75, 5.2, 0.5,
'How much time has passed?',
'#6e2f1a', fontsize=9, bold=True)
# Timeline branches
arrow(ax, 4.4, 7.75, 2.5, 7.0, color='#555')
arrow(ax, 7, 7.5, 7, 7.0, color='#555')
arrow(ax, 9.6, 7.75, 11.5, 7.0, color='#555')
ax.text(2.5, 7.2, '≤ 72 hours', ha='center', fontsize=8.5, color='#555', style='italic')
ax.text(7.0, 7.2, '≤ 120 hours\n(5 days)', ha='center', fontsize=8.5, color='#555', style='italic')
ax.text(11.5, 7.2, '> 5 days', ha='center', fontsize=8.5, color='#555', style='italic')
# ≤72 h options
rounded_box(ax, 2.5, 6.5, 4.0, 0.55,
'All 4 EC options available', '#1f618d', fontsize=9, bold=True)
opts_72 = [
(0.9, 5.6, 'Levonorgestrel\n(Plan B)\nOTC, most\nwidely used'),
(2.5, 5.6, 'Ulipristal\nAcetate\nRx needed;\nbetter near\novulation'),
(4.1, 5.6, 'Copper IUD\nMost effective\noption overall'),
]
for (x, y, lbl) in opts_72:
arrow(ax, 2.5, 6.22, x, 5.98)
rounded_box(ax, x, y, 1.2, 0.75, lbl, '#2e86c1', fontsize=7.5)
# 72h–5d options
rounded_box(ax, 7, 6.5, 4.0, 0.55,
'Copper IUD or Ulipristal', '#117a65', fontsize=9, bold=True)
opts_5d = [
(5.8, 5.6, 'Copper IUD\n≤5 days;\nmost effective\nany weight'),
(8.2, 5.6, 'Ulipristal\nAcetate\n≤5 days;\nbetter than LNG\nnear ovulation'),
]
for (x, y, lbl) in opts_5d:
arrow(ax, 7, 6.22, x, 5.98)
rounded_box(ax, x, y, 2.0, 0.9, lbl, '#148f77', fontsize=7.5)
# >5 days
rounded_box(ax, 11.5, 6.5, 3.5, 0.55,
'EC no longer indicated', '#7b7d7d', fontsize=9, bold=True)
rounded_box(ax, 11.5, 5.6, 3.2, 0.75,
'Counsel on regular\ncontraception\n& pregnancy test',
'#aab7b8', textcolor='#1a1a2e', fontsize=8)
# Q2 – obesity check
arrow(ax, 7, 6.22, 7, 4.65) # from IUD/ulipristal box
rounded_box(ax, 7, 4.4, 5.2, 0.5,
'Is the patient obese / overweight?', '#6e2f1a', fontsize=9, bold=True)
arrow(ax, 4.4, 4.4, 2.5, 3.7, color='#555')
arrow(ax, 9.6, 4.4, 11.0, 3.7, color='#555')
ax.text(2.5, 3.9, 'Yes', ha='center', fontsize=9, color='#922b21', fontweight='bold')
ax.text(11.0, 3.9, 'No', ha='center', fontsize=9, color='#117a65', fontweight='bold')
rounded_box(ax, 2.5, 3.35, 4.2, 0.75,
'Prefer Copper IUD\n(effective regardless of weight)\nor Ulipristal > Levonorgestrel',
'#c0392b', fontsize=8)
rounded_box(ax, 11.0, 3.35, 3.8, 0.75,
'Any appropriate\nEC method\ncan be used',
'#117a65', fontsize=8)
# Copper IUD box – can keep as ongoing contraception
arrow(ax, 7, 4.15, 7, 3.3)
rounded_box(ax, 7, 3.0, 5.8, 0.55,
'If Copper IUD chosen: continue as ongoing contraception (up to 10–12 yr)',
'#8e44ad', fontsize=8.5, bold=False)
# Note panel
ax.add_patch(FancyBboxPatch((0.4, 0.3), 13.2, 2.35,
boxstyle='round,pad=0.05', facecolor='#fdfefe',
edgecolor='#1a1a2e', lw=1.2, zorder=2))
ax.text(7, 2.55, 'KEY PHARMACOLOGY NOTES', ha='center', fontsize=9,
fontweight='bold', color='#1a1a2e', zorder=3)
notes = [
'• Levonorgestrel: delays/inhibits ovulation; OTC; less effective if taken >72 h or in obese women.',
'• Ulipristal acetate (ella): progesterone receptor antagonist; maintains efficacy up to 120 h & closer to ovulation than LNG.',
'• Copper IUD: spermicidal (copper ions) + prevents implantation; most effective EC; works for all body weights; can serve as ongoing contraception for 10–12 years.',
'• Yuzpe (combined OCP) method: highest side effects (nausea/vomiting); least preferred; use only if other methods unavailable.',
'• Probability of pregnancy from unprotected intercourse: average ~8%, but up to 30% near ovulation.',
]
for i, note in enumerate(notes):
ax.text(0.7, 2.25 - i * 0.37, note, fontsize=7.5, color='#2c3e50', va='top', zorder=3)
plt.tight_layout()
plt.savefig('/tmp/workspace/contraceptives/fig3_emergency_contraception.png',
dpi=180, bbox_inches='tight')
plt.close()
print('Fig 3 saved.')
# ─────────────────────────────────────────────────────────────────────────────
# RUN ALL
# ─────────────────────────────────────────────────────────────────────────────
fig1_master()
fig2_hormonal()
fig3_emergency()
print('All figures saved to /tmp/workspace/contraceptives/')
cd /tmp/workspace/contraceptives && python flowcharts.py
fig1 master classification
Image · PNG
fig2 hormonal deepdive
Image · PNG
fig3 emergency contraception
Image · PNG