Replace Matplotlib with a Cross-Platform Visualization Solution
Problem
Hyperkey currently uses Matplotlib for generating visualisations such as:
- Heatmaps
- Spectral measurement graphs
During Android execution through Flet, Matplotlib fails with an error similar to:
[Errno 20] Not a directory:
'/data/user/0/com.flet.hyperkey/files/flet/sitepackages.zip/
matplotlib/mpl-data/matplotlibrc'
Matplotlib expects some of its resource files to exist in a normal filesystem directory, while Flet packages Python dependencies inside sitepackages.zip on Android.
Attempting Android-specific workarounds for Matplotlib would also introduce different visualisation implementations and behaviour between the Windows and Android versions.
Proposed Solution
Replace Matplotlib entirely across all supported platforms, rather than maintaining Matplotlib for Windows and a separate solution for Android.
The replacement should:
- Work reliably on both Windows and Android.
- Maintain a single visualisation implementation across platforms.
- Preserve the current heatmap and spectral graph functionality as closely as possible.
- Continue generating the existing PNG outputs.
- Support the application's light/dark visualisation mode.
- Avoid platform-specific plotting logic wherever possible.
- Minimise changes to the existing pipeline and public module interfaces.
Existing calls such as:
visualise_heatmap.main(...)
visualise_measurement.main(...)
should ideally remain unchanged so the workflow/pipeline does not need significant modification.
Goal
Maintain consistent visualisations, behaviour, output files, and maintainability across Windows and Android using one cross-platform rendering solution.
Acceptance Criteria
Alternative
Try to make Matplotlib work on Android by extracting/providing mpl-data as a real Android filesystem directory and pointing Matplotlib to it (for example via MATPLOTLIBDATA). This lets us potentially keep your existing heatmap and spectral graph code with minimal changes.
- Not Feasible : fixing mpl-data only fixes the error displayed above. Matplotlib could subsequently encounter another Android/Flet-specific issue involving fonts, caches, native libraries, backends, or another resource.
Replace Matplotlib with a Cross-Platform Visualization Solution
Problem
Hyperkey currently uses Matplotlib for generating visualisations such as:
During Android execution through Flet, Matplotlib fails with an error similar to:
Matplotlib expects some of its resource files to exist in a normal filesystem directory, while Flet packages Python dependencies inside
sitepackages.zipon Android.Attempting Android-specific workarounds for Matplotlib would also introduce different visualisation implementations and behaviour between the Windows and Android versions.
Proposed Solution
Replace Matplotlib entirely across all supported platforms, rather than maintaining Matplotlib for Windows and a separate solution for Android.
The replacement should:
Existing calls such as:
should ideally remain unchanged so the workflow/pipeline does not need significant modification.
Goal
Maintain consistent visualisations, behaviour, output files, and maintainability across Windows and Android using one cross-platform rendering solution.
Acceptance Criteria
flet build windowssucceeds.flet build apksucceeds.Alternative
Try to make Matplotlib work on Android by extracting/providing mpl-data as a real Android filesystem directory and pointing Matplotlib to it (for example via MATPLOTLIBDATA). This lets us potentially keep your existing heatmap and spectral graph code with minimal changes.