python - Sympy: generate figure with multiple subplots -
i'm using sympy , matplotlib, , wish generate figure multiple plots, how it's done using pylab.subplot when using numpy. should trivial, or thought...
to surprise didn't find simple way it. either (a) evaluate sympy expression @ multiple points , numpy array can use matplotlib or (b) use mechanism similar pylab.subplot in sympy.plotting.
sample code:
import sympy.plotting.plot symplot import sympy sym x = sym.symbol('x') # opens 2 different figures... symplot(x*x, (x, -10, 10)) symplot(x, (x, -10, 10))
any ideas?
for first question, can use lambdify()
convert expression function:
import numpy np sympy import * x, y = symbols("x, y") eq = sqrt(x**2 + y**2) xa = np.random.rand(10) ya = np.random.rand(10) f = lambdify((x, y),eq,'numpy') print f(xa, ya) print np.sqrt(xa**2 + ya**2)
Comments
Post a Comment