Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a problem that requests that I plot two families of curves:

$$x^2+y^2=r^2\qquad\text{and}\qquad ax+by=0$$

I can get the first family with:

ContourPlot[x^2+y^2,{x,-3,3},{y,-3,3}]

Anyone have a good suggestion for superimposing the second family on the same plot?

share|improve this question
    
Note that the second family of curves may be written y/x = -a/b. Then you can ContourPlot y/x. The numerics near the vertical lines gets finnicky, so you can equivalently plot ArcTan[y/x] or ArcTan[y,x] or anyFunctionOfOneVariable[y/x]. As far as making it look nice in terms of super-imposing, I think other solutions here are good. – evanb Mar 8 at 6:29
s = Table[y - Tan@p x == 0, {p, 0, Pi, Pi/20}];
s1 = Table[y^2 + x^2 == r^2, {r, 0, 4, .3}]; 
ContourPlot[Evaluate@Join[s1, s], {x, -3, 3}, {y, -3, 3}]

Mathematica graphics

share|improve this answer
2  
You should change the first line to s = Table[Cos@p y - Sin@p x == 0, {p, 0, Pi, Pi/20}]; this way you won't miss the x==0 line – BlacKow Mar 7 at 17:27

Perhaps

ParametricPlot[r {Cos[t], Sin[t]}, {r, 0, 2}, {t, 0, 2 Pi},
 Mesh -> {9, 17}, PlotPoints -> 50]

Mathematica graphics

Or

ParametricPlot[r {Cos[t], Sin[t]}, {r, 0, 2 Sqrt[2]}, {t, 0, 2 Pi},
 Mesh -> {Round[9 Sqrt[2]], 17},
 RegionFunction -> Function[{x, y, u, v}, Abs[x] <= 2 && Abs[y] <= 2]]

or even just clip with PlotRange instead of RegionFunction. It produces a cleaner boundary. (Edit: Added some styling.)

ParametricPlot[r {Cos[t], Sin[t]}, {r, 0, 2 Sqrt[2]}, {t, 0, 2 Pi},
 Mesh -> {Round[9 Sqrt[2]], 31}, 
 MeshStyle -> (Directive[Thickness[0.005], Opacity[1], #] & /@ ColorData[97, "ColorList"]),
 BoundaryStyle -> (Directive[Thickness[0.005], Opacity[1], ColorData[97][2]]),
 PlotStyle -> None, Axes -> False, PlotRange -> 2]

Mathematica graphics

share|improve this answer

Closer to OP approach:

ContourPlot[{
  x^2 + y^2 == Range[10], 
  x Range[-10, 10] + y Join[Range[0, 10], Range[9, 0, -1]] == 0}, 
{x, -3, 3}, {y, -3, 3}]

Result:

enter image description here

With slight modification:

ContourPlot[{x^2 + y^2 == Range[1, 6, 0.5]^2, 
  x Range[-6, 6] + y Join[Range[0, 6], Range[5, 0, -1]] == 0}, 
{x, -3, 3}, {y, -3, 3}]

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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