Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions plots/bar-basic/implementations/matplotlib.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
"""
bar-basic: Basic Bar Chart
Library: matplotlib
"""

import matplotlib.pyplot as plt


# Data - Product sales by category
categories = ["Electronics", "Clothing", "Home & Garden", "Sports", "Books", "Toys"]
values = [45200, 32800, 28500, 21300, 18900, 15600]

# Create plot
fig, ax = plt.subplots(figsize=(16, 9))

# Bar chart with Python Blue color
bars = ax.bar(categories, values, color="#306998", width=0.6, edgecolor="white", linewidth=1)

# Add value labels on top of bars
for bar, value in zip(bars, values, strict=True):
height = bar.get_height()
ax.annotate(
f"${value:,}",
xy=(bar.get_x() + bar.get_width() / 2, height),
xytext=(0, 8),
textcoords="offset points",
ha="center",
va="bottom",
fontsize=14,
)

# Labels and styling
ax.set_xlabel("Product Category", fontsize=20)
ax.set_ylabel("Sales ($)", fontsize=20)
ax.set_title("Product Sales by Category", fontsize=20)

# Style tick labels
ax.tick_params(axis="both", labelsize=16)

# Subtle grid on y-axis only
ax.yaxis.grid(True, alpha=0.3, linestyle="-")
ax.set_axisbelow(True)

# Remove top and right spines for cleaner look
ax.spines["top"].set_visible(False)
ax.spines["right"].set_visible(False)

# Set y-axis to start at 0
ax.set_ylim(bottom=0)

plt.tight_layout()
plt.savefig("plot.png", dpi=300, bbox_inches="tight")
18 changes: 18 additions & 0 deletions plots/bar-basic/metadata/matplotlib.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Per-library metadata for matplotlib implementation of bar-basic
# Auto-generated by impl-generate.yml

library: matplotlib
specification_id: bar-basic

preview_url: https://storage.googleapis.com/pyplots-images/plots/bar-basic/matplotlib/plot.png
preview_html: null

current:
version: 0
generated_at: 2025-12-11T22:56:21Z
generated_by: claude-opus-4-5-20251101
workflow_run: 20150015715
issue: 612
quality_score: 92

history: []