import matplotlib.pyplot as plt
import numpy as np
from typing import Callable,Union,Tuple,List
import functools

#######
# Types
#######

# Type of functions float -> float
Function = Callable[[float],float]

###################
# Function plotting
###################

def plotFunctions(lf: list[Function], xrange: tuple[float,float]):
    """" Plot each function in lf over range of x-values xrange and returns the plot """
    #plt.style.use('_mpl-gallery')
    x = np.linspace(xrange[0], xrange[1], 100)
    fig, axes = plt.subplots()
    for f in lf :
        axes.plot(x, f(x), linewidth=2.0, label=f.__name__) # type: ignore
    plt.legend()
    return plt

def plotFunction(f: Function, xrange: tuple[float,float]):
    """ Plot function f over range of x-values xrange and returns the plot """
    return plotFunctions([f], xrange)
