How to overlay when plotting formulas in sympy
import sympy as sym
sym.init_printing()
sym.var("x")
expr = 1/(1+ sym.exp(-x))
ax1 = sym.plot(expr, line_color="blue", show=False)
ax2 = sym.plot(expr.diff(x), line_color="red", show=False)
ax1.extend(ax2)
ax1.show()
sym.var("x")
expr = 1/(1+ sym.exp(-x))
ax1 = sym.plot(expr, expr.diff(x), legend=True, show=False)
ax1[1].line_color="red"
ax1.show()
The legend is displayed with legend = True
.
Recommended Posts