How to Analyze a .FIT File and Create Plots with Gemini CLI

July 10, 2025 Wietse Venema

I often go for a run and track my activities with my Garmin watch. While Garmin Connect and Strava provide some ways to analyze the data, I was curious to see if I could dig deeper into the data myself. Garmin Connect lets you download a .FIT file, a binary format for workout data that's not human-readable. I used Gemini CLI to create insightful plots from that file, without having to write any code from scratch.

Here is one plot that I really liked:

Heart Rate vs. Power Over Time

This plot visualizes my two-hour run, charting heart rate against power, with time shown by the color gradient from purple to yellow. You can see the warm up where I start running at around 300 watts and the heart rate increases (the purple dots climbing). The plot also shows cardiac drift, where my heart rate increases over time at a relatively constant power output. The run finishes with a few peak power efforts topping out at 600 watts, followed by a cool-down where my power drops off, but my heart rate declines more slowly.

Now, let's look at how I created this plot with Gemini CLI. I started with a directory that contained a single .FIT file, and a simple question:

What file is here? Can you read it?

Gemini correctly identified it as a .FIT file. This is possible because on startup, Gemini CLI scans the directory to understand the project's layout. You can read more about how Gemini CLI builds context and learns about your codebase in a previous post.

Gemini offered to write a Python script to parse it. After a few iterations, I had a script that read the file and provided a summary of the activity.

Next, I asked Gemini to come up with some interesting ways to plot the data. It came back with several suggestions:

Of course! There are many ways to visualize your workout data to gain more insights. Here are some ideas for interesting plots we could create:...

It suggested heart rate, speed, and elevation over time, a route map, a heart rate vs. pace scatter plot, a cadence distribution histogram, and a power analysis chart. I asked it to create all of them.

Finally, I had one more specific request:

What about heart rate to power and slowly change the color to indicate time

This led it to create the script that rendered the colorful plot. This is the code it wrote.

Summary

This experiment shows the power of using Gemini CLI for quick explorative data analysis. I was able to go from a binary file to visualizations with just a few prompts. If you're interested in Gemini CLI, you might also want to read my post on exploring the Gemini CLI for more practical tips.

* * *