Skip to content

Instantly share code, notes, and snippets.

@rlabbe
Last active August 29, 2015 14:18
Show Gist options
  • Save rlabbe/8870c25915085194cd8d to your computer and use it in GitHub Desktop.
Save rlabbe/8870c25915085194cd8d to your computer and use it in GitHub Desktop.
Plot linear equations with sympy
from sympy.abc import x, y, z
from sympy.plotting import plot, plot3d
import sympy as sp
fron sympy import solve, Eq
def plot_line(e):
e = solve(e, y)
plot(e[0])
def plot_plane(e):
e = solve(e, z)
plot3d(e[0])
def plot_eq(lhs, rhs):
""" plots equation of form lhs = rhs. e.g to plot x+2y=3, call plot_eq(x+2*y, 3)"""
plot(solve(Eq(lhs, rhs), y)[0])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment