# Any line and label

```
import pylab
import numpy as np

def draw_a_line(formula, x_range, label=''):  
    x = np.array(x_range)  
    y = eval(formula)
    pylab.plot(x, y, '-', label=label)

# draw -x^2
x = np.linspace(-5, 1.5)
y = np.negative(np.power(x, 2))
pylab.plot(x, y, '-k', label = r'$y = -x^2$')

# draw two lines
draw_a_line('2*x + 1', range(-5, 3))
draw_a_line('(2/5)*(x + 1/5) - 1/25', range(-5, 3))

# draw a point
pylab.plot(-1, -1, 'bo', label = r'$y^\prime(1) = -2$')
pylab.plot(-0.2, -1/25, 'ro', label = r'$y^\prime(-\frac{1}{2}) = -\frac{1}{25}$')

pylab.legend(loc='lower right')
pylab.show()
```

![](https://678042047-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Le4Kw7aXTv8Say69hfT%2F-Le4Ky20EiLyi7Fs0_LO%2F-Le4Kznl2_Cdx1_-vxU5%2Fnegative_x%5E2.png?generation=1557015298652796\&alt=media)
