Ask Your Question
0

Label function automaticaly, 2d plot

asked 2018-03-10 18:30:44 -0500

thetha gravatar image

updated 2018-03-10 19:56:02 -0500

kcrisman gravatar image

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 flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
3

answered 2018-03-10 19:59:21 -0500

kcrisman gravatar image

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)+'$')

See this live example.

edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools

1 follower

Stats

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

Seen: 20 times

Last updated: Mar 10