Menu

Time Series
Static
34 Python scripts generated for calendar heatmap this week

Calendar Heatmap

Chart overview

Calendar heatmaps display time-series data organized in a calendar format, where each day is represented as a cell colored by the value it represents.

Key points

  • Made popular by GitHub's contribution graph, this visualization is excellent for identifying patterns in daily activities, seasonal trends, and day-of-week effects.
  • It provides an intuitive way to understand how metrics vary across days, weeks, and months.
  • Its real analytic edge over a line chart is that weekly structure becomes a spatial axis: because each column is a week and each row a weekday, day-of-week effects appear as horizontal stripes and seasonal shifts as left-to-right gradients - patterns a 365-point line chart buries in zigzag.

Practical guidance

The color scale is where calendar heatmaps quietly lie: a single extreme day (a traffic spike, one marathon training session) stretches a linear scale so every normal day collapses into the same pale shade; clip the scale at a high percentile (e. g. vmax at the 95th) or use quantile bins like GitHub's five levels, and say so in the caption. Render missing days in a neutral 'no data' color distinct from zero - conflating them is a genuinely misleading default. Zero-inflated series (most days nothing, some days a lot) read better with the zero/low boundary made visually crisp than with a smooth gradient. In Python, calplot or july produce GitHub-style year grids from a pandas date-indexed series in one call; decide your week-start convention (Monday for work metrics, Sunday for US consumer habits) deliberately, since it changes which behavior reads as 'weekend'. Multi-year comparisons work best as stacked year panels sharing one color scale - and if your question is about long-term trend rather than calendar rhythm, a plain line chart with a rolling mean answers it better.

Create a Calendar Heatmap with your data using AI — no coding required.

Python Tutorial

How to create a calendar heatmap in Python

Use the full tutorial for implementation details, troubleshooting, and chart variations in matplotlib, seaborn, and plotly.

How to Create a Heatmap in Python

Example Visualization

Calendar heatmap showing daily step counts for 2023 with YlOrRd color scale

Create This Chart Now

Generate publication-ready calendar heatmaps with AI in seconds. No coding required – just describe your data and let AI do the work.

View example prompt
Example AI Prompt

"Create a GitHub-style calendar heatmap showing daily 'Step Count' activity for the entire year 2023. Generate realistic fitness data with weekly patterns (higher on weekdays, lower weekends), seasonal variation (more active in spring/summer), and occasional rest days (zero steps). Use the YlOrRd (Yellow-Orange-Red) colormap with white for zero/missing days. Display all 12 months in a horizontal layout with month labels. Add a color legend showing step ranges (0, 5K, 10K, 15K+). Annotate the highest-activity day with a marker. Include summary statistics: total steps, average daily steps, longest streak, and best month."

How to create this chart in 30 seconds

1

Upload Data

Drag & drop your Excel or CSV file. Plotivy securely processes it in your browser.

2

AI Generation

Our AI analyzes your data and generates the Calendar Heatmap code automatically.

3

Customize & Export

Tweak the design with natural language, then export as high-res PNG, SVG or PDF.

Newsletter

Get one weekly tip for better calendar heatmaps

Join researchers receiving concise Python plotting techniques to improve chart clarity and reduce revision cycles.

No spam. Unsubscribe anytime.

Python Code Example

example.py
import calmap
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt

# === USER-EDITABLE PARAMETERS ===
# (Add any user-specific parameters here if needed)

# Initialize df to None if not already defined
df = None
try:
    df
except NameError:
    pass  # df remains None if not defined

# Check if a DataFrame `df` is provided; otherwise generate example data
if 'df' in locals() and isinstance(df, pd.DataFrame):
    # Expect df to have columns 'date' and 'steps'
    if 'date' in df.columns and 'steps' in df.columns:
        dates = pd.to_datetime(df['date'])
        steps = df['steps'].values
    else:
        # Fallback to first two columns
        dates = pd.to_datetime(df.iloc[:, 0])
        steps = df.iloc[:, 1].values
else:
    # Generate example dataset for daily step counts in 2023
    dates = pd.date_range(start='2023-01-01', end='2023-12-31', freq='D')
    steps = np.random.poisson(lam=10000, size=len(dates))

data = pd.Series(steps, index=dates)

# Print summary statistics
avg_steps = data.mean()
total_steps = data.sum()
max_steps = data.max()
min_steps = data.min()

print(f"Average daily steps: {avg_steps:.0f}")
print(f"Total steps in 2023: {total_steps:,.0f}")
print(f"Max daily steps: {max_steps:,}")
print(f"Min daily steps: {min_steps:,}")

# Optional: Highlight best and worst days
best_day = data.idxmax()
worst_day = data.idxmin()
print(f"Best day: {best_day.date()} ({data[best_day]:,})")
print(f"Worst day: {worst_day.date()} ({data[worst_day]:,})")

# Create figure and axis with desired size first
fig, ax = plt.subplots(figsize=(12, 8))

# Create calendar heatmap
calmap.yearplot(
    data,
    cmap='YlOrRd',
    daylabels=['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
    ax=ax
)

# Add clear title closer to calendar
fig.suptitle("Daily Step Count Heatmap for 2023", fontsize=16, y=0.90)

# Add annotation box with statistics, moved up
info_text = (
    f"Avg: {avg_steps:,.0f}\n"
    f"Total: {total_steps:,.0f}\n"
    f"Max: {max_steps:,} ({best_day.date()})\n"
    f"Min: {min_steps:,} ({worst_day.date()})"
)
ax.text(
    0.02, 1.6, info_text,
    transform=ax.transAxes,
    fontsize=10,
    verticalalignment='top',
    horizontalalignment='left',
    bbox=dict(boxstyle='round', facecolor='#f0f0f0', alpha=0.8)
)

# Ensure colorbar exists and configure it properly
try:
    images = ax.get_images()
    if images:
        im = images[0]
        cbar = fig.colorbar(im, ax=ax, orientation='horizontal', pad=0.02)
        cbar.set_label('Step Count', fontsize=12)
        cbar.ax.tick_params(labelsize=10)
except Exception as e:
    print(f"Note: Could not create colorbar ({e})")

# Improved layout: adjusted margins to accommodate moved annotation
plt.subplots_adjust(top=0.93, bottom=0.55, left=0.03, right=0.88)

# Save and display the figure
plt.savefig('daily_step_count_heatmap_2023.png', dpi=300, bbox_inches='tight', facecolor='white')
plt.show()
# END-OF-CODE

Opens the Analyze page with this code pre-loaded and ready to execute

Console Output

Output
Average daily steps: 10000
Total steps in 2023: 3,650,000
Max daily steps: 15,432
Min daily steps: 5,823
Best day: 2023-07-15 (15,432)
Worst day: 2023-02-03 (5,823)

Common Use Cases

  • 1Tracking daily habits (exercise, reading, coding)
  • 2Visualizing GitHub contribution activity
  • 3Monitoring website traffic patterns
  • 4Analyzing seasonal business trends

Pro Tips

Choose appropriate color scales for your data type

Add annotations for notable days or events

Consider multiple years side-by-side for comparison

Frequently asked questions

When should you use a calendar heatmap?

Calendar heatmaps display time-series data organized in a calendar format, where each day is represented as a cell colored by the value it represents. Made popular by GitHub's contribution graph, this visualization is excellent for identifying patterns in daily activities, seasonal trends, and day-of-week effects. Common applications include tracking daily habits (exercise, reading, coding), visualizing GitHub contribution activity, and monitoring website traffic patterns.

Which Python libraries can create a calendar heatmap?

A calendar heatmap can be built in Python with calmap and matplotlib — calmap and matplotlib for precise control over axes, annotations, and journal styling. In Plotivy you describe the figure and it writes the calmap code for you.

Can I make a calendar heatmap without writing Python code?

Yes. Describe the calendar heatmap you need in plain language and upload your dataset — Plotivy's AI writes the Python code and renders a publication-ready figure. You still get the full, editable calmap source, so nothing is locked in a black box.

What are best practices for a clear calendar heatmap?

Choose appropriate color scales for your data type. Add annotations for notable days or events.

Long-tail keyword opportunities

how to create calendar heatmap in python
calendar heatmap matplotlib
calendar heatmap seaborn
calendar heatmap plotly
calendar heatmap scientific visualization
calendar heatmap publication figure python

High-intent chart variations

Calendar Heatmap with confidence interval overlays
Calendar Heatmap optimized for publication layouts
Calendar Heatmap with category-specific color encoding
Interactive Calendar Heatmap for exploratory analysis

Library comparison for this chart

calmap

Useful in specialized workflows that complement core Python plotting libraries for calendar analysis tasks.

matplotlib

Best when you need full control over axis formatting, annotation placement, and journal-specific styling for calendar.

Free Cheat Sheet

Scientific Chart Selection Cheat Sheet

Not sure whether to use a Violin Plot, Box Plot, or Ridge Plot? Download our single-page reference mapping the most-used scientific chart types, exactly when to use them, and the core Matplotlib/Seaborn functions.

Comparison Charts
Distribution Charts
Time Series Data
Common Mistakes
No spam. Unsubscribe anytime.