-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmatplotlib.py
More file actions
50 lines (37 loc) · 1.62 KB
/
matplotlib.py
File metadata and controls
50 lines (37 loc) · 1.62 KB
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
""" anyplot.ai
rose-basic: Basic Rose Chart
Library: matplotlib 3.10.9 | Python 3.13.13
Quality: 80/100 | Updated: 2026-04-30
"""
import matplotlib.pyplot as plt
import numpy as np
# Data - Monthly rainfall (mm) showing seasonal patterns
months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
values = np.array([85, 72, 95, 110, 145, 160, 180, 165, 130, 105, 90, 80])
# Calculate angles - equal segments
n_categories = len(months)
angles = np.linspace(0, 2 * np.pi, n_categories, endpoint=False)
# Create polar plot (4800x2700 px at 300 dpi)
fig, ax = plt.subplots(figsize=(16, 9), subplot_kw={"projection": "polar"})
# Style the polar plot - set BEFORE plotting
ax.set_theta_zero_location("N") # Start from top (12 o'clock)
ax.set_theta_direction(-1) # Clockwise
# Calculate bar width to fill the circle
width = 2 * np.pi / n_categories * 0.9
# Create rose chart using bar plot
ax.bar(angles, values, width=width, bottom=0, color="#306998", edgecolor="white", linewidth=2, alpha=0.85)
# Set category labels at each angle
ax.set_xticks(angles)
ax.set_xticklabels(months, fontsize=18, fontweight="bold")
# Add radial gridlines with labels
ax.set_ylim(0, max(values) * 1.15)
ax.yaxis.set_tick_params(labelsize=14)
# Style the radial grid
ax.grid(True, alpha=0.3, linestyle="--", linewidth=1.5)
ax.spines["polar"].set_visible(True)
ax.spines["polar"].set_linewidth(2)
ax.spines["polar"].set_color("#306998")
# Title
ax.set_title("Monthly Rainfall (mm) · rose-basic · matplotlib · pyplots.ai", fontsize=24, fontweight="bold", pad=30)
plt.tight_layout()
plt.savefig("plot.png", dpi=300, bbox_inches="tight")