[PYTHON] Overlay graphs with sympy

Overlay graphs with sympy

How to overlay when plotting formulas in sympy

import sympy as sym
sym.init_printing()

Part 1

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()

download.png

Part 2

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.

download.png

Recommended Posts

Overlay graphs with sympy
With Sympy, don't worry
[Python] Solve equations with sympy
Use directional graphs with networkx
Equation of motion with sympy
Animate multiple graphs with matplotlib
Publish nice graphs online with plotly
Play with Poincare series and SymPy
Writing C language with Sympy (metaprogramming)
Free from hard-coding functions with SymPy
Multiple integrals with Python and Sympy
Easy to draw graphs with matplotlib
Application of graphs with plotly sliders
Write SVG graphs with matplotlib on heroku
Display Japanese graphs with VS Code + matplotlib
Overlay background diagram, contour diagram, vector diagram with python