✔ Copied

advanced_wheel.py

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
import matplotlib.pyplot as plt
from matplotlib.patches import Wedge
import numpy as np
import textwrap

# ----------------------------
# Wheel Data
# ----------------------------

sections = [
    ("Physical Environment", "Home, Location, Appearance, Transport"),
    ("Career / Work", "Work hours, Career direction, Purpose, Performance"),
    ("Financial Security", "Budgeting, Saving, Income, Investment"),
    ("Health / Wellbeing", "Diet, Fitness, Sleep, Relaxation, Emotional health, Self-care"),
    ("Family / Friends", "Relationships, Time, Quality, Support, Community"),
    ("Relationship / Romance", "Partner, Communication, Intimacy, Space"),
    ("Personal Growth", "Education, Learning, Reading, Awareness, Spirituality"),
    ("Fun / Recreation", "Leisure, Hobbies, Passions, Laughter"),
]

# ----------------------------
# Parameters
# ----------------------------

radius = 2.0
title_radius = 0.78
subtitle_radius = 0.50

title_fontsize = 20
subtitle_fontsize = 12

title_wrap = 14
subtitle_wrap = 22

figure_size = 20

# ----------------------------
# Helper Functions
# ----------------------------

def wrap_text(text, width):
    return "\n".join(textwrap.wrap(text, width))

def place_text(ax, x, y, text, fontsize, weight="normal"):
    return ax.text(
        x,
        y,
        text,
        ha="center",
        va="center",
        fontsize=fontsize,
        weight=weight
    )

# ----------------------------
# Build Wheel
# ----------------------------

n = len(sections)
angles = np.linspace(0, 360, n + 1)

fig, ax = plt.subplots(figsize=(figure_size, figure_size))

colors = plt.get_cmap("tab20").colors[:n]

for i in range(n):

    start = angles[i]
    end = angles[i + 1]

    wedge = Wedge(
        (0, 0),
        radius,
        start,
        end,
        facecolor=colors[i],
        edgecolor="white",
        linewidth=4
    )

    ax.add_patch(wedge)

# ----------------------------
# Place Text
# ----------------------------

for i, (title, subtitle) in enumerate(sections):

    angle = (angles[i] + angles[i + 1]) / 2
    rad = np.deg2rad(angle)

    # Title position
    tx = radius * title_radius * np.cos(rad)
    ty = radius * title_radius * np.sin(rad)

    # Subtitle position
    sx = radius * subtitle_radius * np.cos(rad)
    sy = radius * subtitle_radius * np.sin(rad)

    wrapped_title = wrap_text(title, title_wrap)
    wrapped_subtitle = wrap_text(subtitle, subtitle_wrap)

    place_text(ax, tx, ty, wrapped_title, title_fontsize, "bold")
    place_text(ax, sx, sy, wrapped_subtitle, subtitle_fontsize)

# ----------------------------
# Formatting
# ----------------------------

ax.set_aspect("equal")
ax.set_xlim(-2.3, 2.3)
ax.set_ylim(-2.3, 2.3)
ax.axis("off")

ax.set_title(
    "Wheel of Life – Balance Across Key Areas",
    fontsize=30,
    pad=40
)

# ----------------------------
# Export
# ----------------------------

plt.savefig("wheel_of_life.png", dpi=300, bbox_inches="tight")
plt.savefig("wheel_of_life.svg", bbox_inches="tight")
plt.savefig("wheel_of_life.pdf", bbox_inches="tight")

plt.show()