Ask Your Question

# Label function automaticaly, 2d plot

Function:

def random_between(j,k):
a=int(random()*(k-j+1))+j
return a

t = var('t')

m1=random_between(-5,5)
b1=random_between(-5,5)
y1=m1*t+b1

m2=random_between(-5,5)
b2=random_between(-5,5)
y2=m2*t+b2

m3=random_between(-5,5)
b3=random_between(-5,5)
y3=m3*t+b3

m4=random_between(-5,5)
b4=random_between(-5,5)
y4=m4*t+b4

p1=plot(y1, (t,-5,5), gridlines=True,color='red')
p2=plot(y2, (t,-5,5), gridlines=True,color='green')
p3=plot(y3, (t,-5,5), gridlines=True,color='orange')
p4=plot(y4, (t,-5,5), gridlines=True,color='pink')
p=p1+p2+p3+p4
show(p)


Well, I would like to view full grid, and auto lable functions, is this possible, i have here 3 Books, do i have to look somewhere else?

edit retag close merge delete

## 1 answer

Sort by ยป oldest newest most voted

The secret sauce is that you can ask legend_label to use the LaTeX representation of the function like so:

p1=plot(y1, (t,-5,5), gridlines=True,color='red', legend_label='$'+latex(y1)+'$')

more

## Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

## Stats

Asked: 2018-03-10 18:30:44 -0600

Seen: 58 times

Last updated: Mar 10 '18