Making it easier to show matplotlib charts in FastHTML.
You can install this tool by running:
python -m pip install fh-matplotlib
After this step, it is ready for use! At the moment this package merely contains a decorator. You can use it to wrap any function that generates a matplotlib chart in order for it to return an Img
for FastHTML to render. In, short you would typically use it like this:
import numpy as np
import matplotlib.pylab as plt
from fh_matplotlib import matplotlib2fasthtml
# This function will return a proper Img that can be rendered
@matplotlib2fasthtml
def matplotlib_function():
plt.plot(np.arange(25), np.random.exponential(1, size=25))
This repository is originally meant to be simple helper, but if there are more advanced use-cases to consider I will gladly consider them. Please start a conversation by opening up an issue before starting a PR though.