I have the following code:
using Plots
f(x) = sin(x)
plot(1:10, f.(1:10); label="$f") # This works as expected; the label is "f".
g = f ∘ f
plot(1:10, g.(1:10); label="$g") # The label here is "Main.f ∘ Main.f", but I want it to be "f ∘ f".
The Main
module prefix appears in the label when plotting composed functions. Is there a way to generate the correct label dynamically (e.g., “f ∘ f”) without manually specifying it? Ideally, I’d like this to work even if I compose functions multiple times (e.g., f ∘ f ∘ f
).
How can I achieve this? Is there a general solution for automatically generating labels for such composed functions?