[PR #23] [CLOSED] Fix matplotlib import error with lazy import and fallback colors #80

Closed
opened 2026-05-07 00:18:33 +02:00 by BreizhHardware · 0 comments

📋 Pull Request Information

Original PR: https://github.com/IAmTomShaw/f1-race-replay/pull/23
Author: @Jal-Bafana
Created: 12/2/2025
Status: Closed

Base: mainHead: main


📝 Commits (1)

  • eca3d31 Fix matplotlib import error with lazy import and fallback colors

📊 Changes

1 file changed (+88 additions, -32 deletions)

View changed files

📝 src/f1_data.py (+88 -32)

📄 Description

Problem

The application fails to start on Python 3.13 due to a matplotlib import error when importing fastf1.plotting at module level.

Solution

  • Made fastf1.plotting import lazy (only when needed)
  • Added fallback color scheme when plotting module cannot be imported
  • Application now works even if matplotlib has compatibility issues

Changes

  • Removed top-level import fastf1.plotting
  • Wrapped import in try/except with fallback in get_driver_colors()
  • Added team-based color mapping as fallback

Testing

Tested on Python 3.13 where original code failed. Application now starts successfully.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/IAmTomShaw/f1-race-replay/pull/23 **Author:** [@Jal-Bafana](https://github.com/Jal-Bafana) **Created:** 12/2/2025 **Status:** ❌ Closed **Base:** `main` ← **Head:** `main` --- ### 📝 Commits (1) - [`eca3d31`](https://github.com/IAmTomShaw/f1-race-replay/commit/eca3d3127e380068345796d0dca88ccef52d87ac) Fix matplotlib import error with lazy import and fallback colors ### 📊 Changes **1 file changed** (+88 additions, -32 deletions) <details> <summary>View changed files</summary> 📝 `src/f1_data.py` (+88 -32) </details> ### 📄 Description ## Problem The application fails to start on Python 3.13 due to a matplotlib import error when importing `fastf1.plotting` at module level. ## Solution - Made `fastf1.plotting` import lazy (only when needed) - Added fallback color scheme when plotting module cannot be imported - Application now works even if matplotlib has compatibility issues ## Changes - Removed top-level `import fastf1.plotting` - Wrapped import in try/except with fallback in `get_driver_colors()` - Added team-based color mapping as fallback ## Testing Tested on Python 3.13 where original code failed. Application now starts successfully. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
BreizhHardware 2026-05-07 00:18:33 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/f1-race-replay#80
No description provided.