Don't get me wrong I can easily do it on paper and I could probably write convoluted code that will get the job done but I feel like there has to be an easy Mathematica way to do this. A few users on here came to my rescue and showed me how to plot linear equations from a matrix but they use ContourPlot and ContourPlot3D. I want to try to do this with other graphing options such as Plot and Plot3D. Below I have a few samples of matrices I wish to create lines and planes from. I think the key here is to find an efficient way to grab two or three points from each matrix row or equation.

    (* line's and plane's from this *)
    m3 = {{1, 0, 1}, {-1, 3, 1}, {3, 4, 5}};
    b3 = {3, 2, 4};

    (* line's from this *)
    m2 = {{1, 2}, {3, 1}};
    b2 = {1, -2};

   (* These are the resulting linear equations and solutions *)

    eqns = m2.{x, y} == b2
    Solve[eqns, {x, y}]
    Reduce[eqns, {x, y}]

    eqns = m3.{x, y, z} == b3
    Solve[eqns, {x, y, z}]
    Reduce[eqns, {x, y, z}]

1 Answer 1


Maybe this way with Hyperplane? Note that the $i$-th row of the matrix is a normal vector to the hyperplane defined by the $i$-th equation.

m3 = {{1, 0, 1}, {-1, 3, 1}, {3, 4, 5}};
b3 = {3, 2, 4};
p = LinearSolve[m3,b3];

  Sphere[p, Scaled[0.02]],
  Table[Hyperplane[n, p], {n, m3}]
 PlotRange -> All
  • $\begingroup$ Uh, oh, thank you for telling me. I added it. $\endgroup$ Jun 16, 2020 at 8:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.