2
$\begingroup$

I am wondering why the following does not work:

eqns = Table[x + n y == n, {n, 1, 3}]  
ContourPlot[eqns, {x, -2, 2}, {y, -1, 2}]

However, if I copy the output of 'eqns' and paste in directly to the contour plot function, I do get the contour plot:

ContourPlot[{x + y == 1, x + 2 y == 2, x + 3 y == 3}, {x, -2, 2}, {y, -1, 2}]
To me they are one and the same.

$\endgroup$

closed as off-topic by m_goldberg, MarcoB, Michael E2, user9660, Jason B. Jan 14 '16 at 10:41

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – m_goldberg, Michael E2, Community, Jason B.
If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ Works for me: i.stack.imgur.com/eoARJ.png (Mathematica 10.1) $\endgroup$ – Rahul Jan 13 '16 at 21:14
  • $\begingroup$ Works fine with 10.3.1 on Win 8.1 Pro 64bit $\endgroup$ – Edmund Jan 14 '16 at 9:34
4
$\begingroup$

Don't forget Evaluate!

eqns = Table[x + n y == n, {n, 1, 3}]
ContourPlot[Evaluate@eqns, {x, -2, 2}, {y, -1, 2}]

enter image description here

$\endgroup$
  • $\begingroup$ Thanks. Sorry I can't up your points yet. $\endgroup$ – PMay Jan 13 '16 at 19:38
  • $\begingroup$ @PMay. Yes you can. You can't up-vote, but you can award 15 reputation points by accepting the answer. Click on the check-mark just below the down arrow on the left of the answer. $\endgroup$ – m_goldberg Jan 13 '16 at 21:56

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