Ask Your Question

Revision history [back]

The following might be a step in the right direction.

Define a list of functions to plot:

sage: ff = [
....:     lambda x: 1 + exp(-x^2/8)*sin(x^2)/x^1,
....:     lambda x: 2 + exp(-x^2/8)*sin(x^3)/x^2,
....:     lambda x: 3 + exp(-x^2/8)*sin(x^4)/x^3,
....:     lambda x: 4 + exp(-x^2/8)*sin(x^5)/x^4,
....:     ]

Initialize an empty graphics object:

sage: p = Graphics()

Set some text options:

sage: text_options = {
....:     'horizontal_alignment': 'right',
....:     'vertical_alignment': 'bottom',
....:     'fontsize': 'large'}

Plot each function and add a label at the end of the curve:

sage: for i, f in enumerate(ff):
....:     p += plot(f, (-5, 5), hue=(2*i+1)/10)
....:     p += text('$y = f_{}(x)$'.format(i), (5, f(5)), **text_options)

Show the result:

sage: p.show()

Curves with labels