juliagadfly

Labelling functions in Gadfly plot


Plotting functions directly is easy in Gadfly:

plot([sin, cos], 0, 25)

This gives my two differently colored lines, automatically labelled in the legend as something like f_1 and f_2:

enter image description here

How can I change the default names in the "Color" legend?


Solution

  • Set the color argument to a list of labels:

    plot([sin, cos], 0, 25, color=["sine", "cosine"])
    

    Update labels