I absolutely adore LaTeX generated documents and personally use it pretty much for anything I can. Plotting graphs is one of my favorite thing to do. TikZ library makes it quite easy. To plot a piecewise function, I happened to learn about \tikzmath which I have never used before. Using it, you can define values and also perform math operations. I used this approach to set values and plot the graph dynamically.