LRowing
LRowing

Reputation: 1

Can you help me out with line colors in plot

I want to change the color of the line but I have no idea how I should code.

import numpy as np
from sympy import *
import sympy as sp
t=sp.symbols('t')
y=sp.Function('y')

overdamped = Eq(10*y(t).diff(t,2)+100*y(t).diff(t,1)+90*y(t),0)
psol1=dsolve(overdamped,ics={y(0):0.16, y(t).diff(t).subs(t,0):0})

underdamped = Eq(10*y(t).diff(t,2)+10*y(t).diff(t,1)+90*y(t),0)
psol3=dsolve(underdamped,ics={y(0):0.16, y(t).diff(t).subs(t,0):0})

plot(psol1.rhs, psol3.rhs, (t,0,10))

This is the work I've done. The plot works well but I want the two lines to be in differnt colors. I'll be very thankful if you help me out.

Upvotes: 0

Views: 58

Answers (1)

johann
johann

Reputation: 234

import numpy as np
from sympy import *
import sympy as sp
t=sp.symbols('t')
y=sp.Function('y')

overdamped = Eq(10*y(t).diff(t,2)+100*y(t).diff(t,1)+90*y(t),0)
psol1=dsolve(overdamped,ics={y(0):0.16, y(t).diff(t).subs(t,0):0})

underdamped = Eq(10*y(t).diff(t,2)+10*y(t).diff(t,1)+90*y(t),0)
psol3=dsolve(underdamped,ics={y(0):0.16, y(t).diff(t).subs(t,0):0})

p = plot(psol1.rhs, psol3.rhs, (t,0,10))
p[0].line_color = 'g'
p[1].line_color = 'r'

p.show()

Upvotes: 1

Related Questions