How to extract all coefficients in sympy

all_coeffs() can be sometime better than using coeffs() for a Poly. The difference lies in output of these both. coeffs() returns a list containing all coefficients which has a value and ignores those whose coefficient is 0 whereas all_coeffs() returns all coefficients including those whose coefficient is zero. >>> a = Poly(x**3 + a*x**2 – … Read more

How do I use the markers parameter of a sympy plot?

Nice find! The documentation doesn’t make things clear. Diving into the source code, leads to these lines in plot.py: for marker in parent.markers: # make a copy of the marker dictionary # so that it doesn’t get altered m = marker.copy() args = m.pop(‘args’) ax.plot(*args, **m) So, sympy just calls matplotlib’s plot with: the args … Read more

how to handle an asymptote/discontinuity with Matplotlib

By using masked arrays you can avoid plotting selected regions of a curve. To remove the singularity at x=2: import matplotlib.numerix.ma as M # for older versions, prior to .98 #import numpy.ma as M # for newer versions of matplotlib from pylab import * figure() xx = np.arange(-0.5,5.5,0.01) vals = 1/(xx-2) vals = M.array(vals) mvals … Read more

Is it possible to plot implicit equations using Matplotlib?

I don’t believe there’s very good support for this, but you could try something like import matplotlib.pyplot from numpy import arange from numpy import meshgrid delta = 0.025 xrange = arange(-5.0, 20.0, delta) yrange = arange(-5.0, 20.0, delta) X, Y = meshgrid(xrange,yrange) # F is one side of the equation, G is the other F … Read more

tech