# Plotting a family of equations

I want to plot a family of equations for different values of $C$. For example $x^2+y^2=C$. How?

I found out that this doesn't work:

ContourPlot[x^2 + y^2 == C /. C -> Range[0, 5], {x, -10, 10}, {y, -10, 10}]


What will work?

Thanks!

• What you're looking for is the option Contours -> Range[0, 5]. Get rid of the == C and add that option after the domain specification. Oct 12, 2015 at 20:19
• Welcome to Mathematica.SE! I suggest the following: 0) Browse the common pitfalls question 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Read the faq! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! Oct 12, 2015 at 21:53

Try mapping the plotting function over the range of interest. Like this:

Map[ContourPlot[x^2 + y^2 == #, {x, -10, 10}, {y, -10, 10}] & , Range[0, 5]]


or in op form:

ContourPlot[x^2 + y^2 == #, {x, -10, 10}, {y, -10, 10}] &  /@  Range[0, 5]


or all the plots together:

cplots = Map[  ContourPlot[x^2 + y^2 == #, {x, -10, 10}, {y, -10, 10}] & ,
Range[0, 5]];
Show[cplots]


Hope this helps Cheers!

• @Imre: I tried to answer your question using general functional programming concepts (in this case mapping a function over a range), keeping your code as intact as possible. Assuming that your code reflects your way to think about a problem, chances are that you may be able to apply this solution in different contexts. However, Belisarius' answer below is more idiomatic. (@march's comment also points out the use of Contours -> Range option). Oct 13, 2015 at 12:46
ContourPlot[x^2 + y^2, {x, -10, 10}, {y, -10, 10},
Contours -> Range[0, 100, 10], ContourShading -> None]


• @Imre, belisarius: I think this is a better answer. More idiomatic and representative of the gazillion options packed in Wolframatica's high-level functions. Oct 13, 2015 at 12:40
• @paramecium Thanks. I also believe that. The problem with accepting non-optimal answers is that future users will get those as the "best" method available misguiding them. Anyway that happens a lot here. BTW, I alredy upvoted your answer :) Oct 13, 2015 at 15:28