Python In Cycling Shoes: A Visual Guide To Heatmaps

Using Python in cycling shoes can be the key to transforming your cycling data into insight-rich visual maps.

If you’re already collecting information like cadence, force, or pedal contact time, you’re just a few steps away from creating graphs that truly show where and how you can improve.

With heatmaps, you can visualize zones of increased effort, identify asymmetries between your feet, and adjust your technique more precisely. And best of all, you don’t need to be a programming expert, just follow a simple step-by-step guide with matplotlib and imshow, without relying on seaborn.

In this guide, we’ll explore practical ways to apply Python to cycling shoes with practical examples, commented code, and visual cues to help you get the most out of your training. Shall we?

Why use heatmaps in cycling?

For those who train frequently, understanding what the body is doing while pedaling is essential. With heatmaps, you can:

  • Visualize pressure zones on your foot when wearing shoes.
  • Observe cadence behavior throughout the ride.
  • Identify performance differences between legs.

It’s important to emphasize that these graphs facilitate the understanding of complex data and help you make decisions about pedal, shoe, and even bike adjustments.

Setting up your environment with matplotlib

To get started, you only need two libraries: matplotlib and numpy. Here’s how to import them:

python

CopyEdit

import numpy as np

import matplotlib.pyplot as plt

Another important point to consider is that we won’t be using seaborn here. We’ll explore pure, lightweight solutions with imshow, which is powerful and highly customizable.

Creating your first heatmap with imshow

Let’s now explore in more detail how to create a simple heatmap with dummy performance data.

python

CopyEdit

data = np.array([

[300, 320, 310],

[290, 305, 315],

[280, 295, 300]

])

plt.imshow(data, cmap=’hot’, interpolation=’nearest’)

plt.title(“Force Distribution by Foot Zone”)

plt.colorbar(label=’Watts’)

plt.xlabel(‘Forefoot → Heel’)

plt.ylabel(‘Left Foot → Right Foot’)

plt.show()

Explaining each part:

  • data: 3×3 matrix with simulated power data.
  • cmap=’hot’: defines the color scale (in this case, heat tones).
  • interpolation=’nearest’: prevents blurring between quadrants.
  • colorbar: adds a legend with the unit of measurement.

Customizing your color palette

It’s also worth noting that color choice greatly impacts the readability of the graph. Here are some options that work well:

  • ‘viridis’: great for color blindness, with pleasant contrast.
  • ‘coolwarm’: good for showing positive and negative variations.
  • ‘plasma’: vibrant colors, great for presentations.

To better understand, see the example below with an alternative colormap:

python

CopyEdit

plt.imshow(data, cmap=’coolwarm’, interpolation=’bilinear’)

How to add annotations to values

Let’s delve a little deeper into this topic by showing how to display the values directly on the graph:

python

CopyEdit

for i in range(data.shape[0]):

for j in range(data.shape[1]):

plt.text(j, i, f'{data[i, j]}’, ha=’center’, va=’center’, color=’white’)

This helps you quickly see where performance peaks or dips are without having to interpret the color scale.

Alternatives to imshow: More visual control

If you want to explore beyond the basics, you can try:

  • pcolormesh: More flexible for non-uniform data.
  • matshow: Similar to imshow, but with automatic axis adjustments.

Python

CopyEdit

plt.pcolormesh(data, cmap=’plasma’, edgecolors=’k’, linewidth=0.01)

This alternative allows for a more technical visualization, great for reports or comparative studies.

Applying to the context: Python in cycling shoes

Let’s imagine you captured data with sensors on your shoes to understand the distribution of force during pedaling.

You can convert this into a heatmap with:

  • Axes representing regions of the foot
  • Intensity related to applied power
  • Comparison between the left and right foot

This type of visualization allows for precise adjustments to cleat position, shoe model, or even the type of pedal you use.

Testing different visual interpolators

imshow allows you to use interpolations to smooth or pixelate the data. Here are some options that completely change the look:

python

CopyEdit

plt.imshow(data_array, cmap=’plasma’, interpolation=’bicubic’)

  • nearest: square, no smoothing (more accurate)
  • bilinear: slight smoothing
  • bicubic: stronger smoothing
  • gaussian: simulates blurring

It’s also worth noting that visual testing helps you better understand what works with your data — there’s no single correct way.

Complete Example: From Scratch to a Finished Graph

Here’s a complete example with simulated data:

python

CopyEdit

import numpy as np

import matplotlib.pyplot as plt

data = np.array([

[280, 300, 310], # left foot

[270, 295, 305] # right foot

])

fig, ax = plt.subplots(figsize=(6, 4))

heatmap = ax.imshow(data, cmap=’viridis’, interpolation=’nearest’)

# Notes

for i in range(data.shape[0]):

for j in range(data.shape[1]):

ax.text(j, i, f'{data[i, j]}’, ha=’center’, va=’center’, color=’white’)

# Labels

ax.set_xticks([0,1,2])

ax.set_xticklabels([‘Front’, ‘Middle’, ‘Heel’])

ax.set_yticks([0,1])

ax.set_yticklabels([‘Left’, ‘Right’])

plt.title(‘Power Distribution by Foot Region’)

plt.colorbar(heatmap, label=’Watts’)

plt.tight_layout()

plt.show()

Result: a clean, informative graph ready for analysis or sharing.

How to interpret your cycling shoe heatmap

With the graph in hand, you can:

  • Compare force zones between feet
  • Identify biomechanical imbalances
  • Assess whether pressure is concentrated in incorrect areas (e.g., heel)

This reading is ideal for high-performance training or even for adjusting the position of cleats on your shoes.

Additional tools that can complement your analysis

It’s also worth highlighting some tools that pair well with heatmaps:

Visual tips that make your graph stand out

Here are some practical suggestions to make your heatmaps more elegant:

  • Use figsize=(8,6) to improve the image aspect ratio.
  • Replace the axis ticks with custom labels.
  • Save in high resolution with plt.savefig(“heatmap.png”, dpi=300).

Another important point to consider: you can combine these heatmaps with other metrics like heart rate, pedal time, and cadence, creating a complete view of your workout.

Practical and curious tips that few share

  • Use inverted scales to highlight critical areas (e.g., heel with less force).
  • Add a dividing line between feet on the graph.
  • Try saving as SVG for presentation-ready vector graphics.
  • Note the variation of each training session and compare it to previous maps.
  • Use plt.tight_layout() to avoid cropping and make the graph cleaner.

These are simple tricks that make your graphs more professional and useful in everyday life.

Conclusion: Python in Cycling Shoes

In this guide, you learned how to create high-quality heatmaps using only matplotlib, and without relying on seaborn. We explored how to set up your environment, adjust color scales, add annotations, and apply it all to the real world of cycling.

The benefits are clear: clearer data, more accurate decisions, and more confidence when riding. Now it’s your turn!

Try applying these techniques to your training today. Analyze your data, generate your own heatmaps, and discover patterns that can transform your performance on two wheels.

Visualize better. Train better. Evolve with Python.

Foto Autor: Camila Torres

Camila Torres

I'm Camila, a materials engineer and cyclist passionate about sustainable solutions. At PedalShoes.com.br, I share what I learn (and test in practice) about cycling shoes that respect your body and the planet.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top