import sys from matplotlib import pyplot as plt from numint.riemann_sum import numint_epsilon from numint.input_parser import parse_function, parse_value def plot_cli(function_expr:str, start:str, end:str, epsilon: str): f = parse_function(function_expr) (a, b) = (parse_value(start), parse_value(end)) eps = parse_value(epsilon) (x, y, l, r, n) = numint_epsilon(f, a, b, eps) fig, ax = plt.subplots() ax.stairs(y[1:], x, baseline=0, fill=True, alpha=1,label=function_expr) ax.stairs(y[0:-1], x, baseline=0, fill=True, color="orange", alpha=0.5, label=function_expr) #ax.step(x, y, label=function_expr) #ax.step(x, y, where="post", label=function_expr) ax.plot(x, y, color="black") plt.show() pass def main(): function_expr = sys.argv[1] start = sys.argv[2] end = sys.argv[3] eps = sys.argv[4] plot_cli(function_expr, start, end, eps) if __name__ == "__main__": main()