plot() handles color names for RGB color codes. SymPy document doesn’t explain it clearly or sample codes don’t exit.

p = plot(sin(x), show=False)
# (red, green, blue)
# define lambda function for varying colors by coordinates or values.
# p[0].line_color = (0.9,0.0,0.0)
p[0].line_color = 'firebrick' # royalblue
p.show()

# 31.
x = symbols('x')
y = (sqrt(x)/(1 + x))**2
dy = diff(y, x)
yl = 10
plot(y, (x, -5, 5), ylim=(-yl, 1), title=str(y), line_color='firebrick')

Here is another example.

# 65
# f(x) = x**2, [-1, 0) and -x**2, [0, 1]
x = symbols('x')
f1 = x**2
f2 = -x**2
# plot() allows only one line_color argument
p = plot((f1, (x, -1, 0)), (f2, (x, 0, 1)), title="x**2 for [-1, 0), -x**2 for [0, 1]", show=False)
p[0].line_color = 'blue'
p[1].line_color = 'green'
p.show()

### Like this:

Like Loading...

*Related*

##
About janpenguin

Email: k2.mountain [at] gmail [dot] com
Every content on the blog is made by Free and Open Source Software in GNU/Linux.

Thanks a million! I was not understanding what they ment by indexing the plots. Your examples made it all clear.