Skip to content

Replace Matplotlib with a Cross-Platform Visualization Solution #52

Description

@ChikithRishi

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

  • Matplotlib and its Matplotlib-specific dependencies are removed.
  • The same visualisation implementation is used on Windows and Android.
  • Heatmap generation works on both platforms.
  • Spectral graph generation works on both platforms.
  • Existing output naming and PNG generation are preserved.
  • Light and dark visualisation modes continue to work.
  • Existing pipeline interfaces require minimal or no changes.
  • Windows and Android outputs are visually consistent.
  • flet build windows succeeds.
  • flet build apk succeeds.
  • Visualisation generation works successfully after installing the APK on an Android device.
Image

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.

Metadata

Metadata

Labels

studentIssues picked up by TechLauncher team human review

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions