Skip to main content
added 46 characters in body
Source Link
kglr
  • 400.5k
  • 18
  • 488
  • 929

You can also use TransformedField to get a function that can be used as the first argument of ContourPlot:

 f = (r^2 - a^3/r) Sin[t]^2;
 tf = TransformedField[ "Polar" -> "Cartesian", f, {r, t} -> {x, y}]

TeXForm @ tf

$\frac{y^2 \left(x^2 \sqrt{x^2+y^2}+y^2 \sqrt{x^2+y^2}-1\right)}{\left(x^2+y^2\right)^{3/2}}$

cValues = {0.00001, 0.01, 0.05, 0.1, 0.3, 0.6, 1.0, 1.5, 2.0, 2.5, 3.2};
a = 1;

ContourPlot[tf, {x, -3, 3}, {y, -3, 3}, 
  Contours -> cValues, 
  PlotPoints-> 200,
  Axes -> True,
  Frame -> False,
  PlotRange -> All, 
  ContourShading -> None, 
  AspectRatio -> Automatic,
  RegionFunction -> (Norm[{#, #2}] <= 3&)]

enter image description here

An alternative approach is to use f with ContourPlot and post-process the output to transform the lines:

cp1 = ContourPlot[f, {r, 0, 3}, {t, -Pi, Pi}, 
       Contours -> cValues, PlotRange -> All, 
       ContourShading -> None,  Axes -> True, 
       Frame -> False, ImageSize -> 300];

cp2 = Show[cp1 /. GraphicsComplex[c_, rest___] :> 
        GraphicsComplex[c /. {a_, b_} :> (a {Cos[b], Sin[b]}), rest], 
    AspectRatio -> Automatic, ImageSize -> 300];

Row[{cp, cp2}, Spacer[15]]

enter image description here

You can also use TransformedField to get a function that can be used as the first argument of ContourPlot:

 f = (r^2 - a^3/r) Sin[t]^2;
 tf = TransformedField[ "Polar" -> "Cartesian", f, {r, t} -> {x, y}]

TeXForm @ tf

$\frac{y^2 \left(x^2 \sqrt{x^2+y^2}+y^2 \sqrt{x^2+y^2}-1\right)}{\left(x^2+y^2\right)^{3/2}}$

cValues = {0.00001, 0.01, 0.05, 0.1, 0.3, 0.6, 1.0, 1.5, 2.0, 2.5, 3.2};
a = 1;

ContourPlot[tf, {x, -3, 3}, {y, -3, 3}, 
  Contours -> cValues, 
  PlotPoints-> 200,
  Axes -> True,
  Frame -> False,
  PlotRange -> All, 
  ContourShading -> None, 
  AspectRatio -> Automatic,
  RegionFunction -> (Norm[{#, #2}] <= 3&)]

enter image description here

You can use TransformedField to get a function that can be used as the first argument of ContourPlot:

 f = (r^2 - a^3/r) Sin[t]^2;
 tf = TransformedField[ "Polar" -> "Cartesian", f, {r, t} -> {x, y}]

TeXForm @ tf

$\frac{y^2 \left(x^2 \sqrt{x^2+y^2}+y^2 \sqrt{x^2+y^2}-1\right)}{\left(x^2+y^2\right)^{3/2}}$

cValues = {0.00001, 0.01, 0.05, 0.1, 0.3, 0.6, 1.0, 1.5, 2.0, 2.5, 3.2};
a = 1;

ContourPlot[tf, {x, -3, 3}, {y, -3, 3}, 
  Contours -> cValues, 
  PlotPoints-> 200,
  Axes -> True,
  Frame -> False,
  PlotRange -> All, 
  ContourShading -> None, 
  AspectRatio -> Automatic,
  RegionFunction -> (Norm[{#, #2}] <= 3&)]

enter image description here

An alternative approach is to use f with ContourPlot and post-process the output to transform the lines:

cp1 = ContourPlot[f, {r, 0, 3}, {t, -Pi, Pi}, 
       Contours -> cValues, PlotRange -> All, 
       ContourShading -> None,  Axes -> True, 
       Frame -> False, ImageSize -> 300];

cp2 = Show[cp1 /. GraphicsComplex[c_, rest___] :> 
        GraphicsComplex[c /. {a_, b_} :> (a {Cos[b], Sin[b]}), rest], 
    AspectRatio -> Automatic, ImageSize -> 300];

Row[{cp, cp2}, Spacer[15]]

enter image description here

added 46 characters in body
Source Link
kglr
  • 400.5k
  • 18
  • 488
  • 929

You can also use TransformedField to get a function that can be used as the first argument of ContourPlot:

 tff = TransformedField[ "Polar"(r^2 -> "Cartesian",a^3/r) Sin[t]^2;
 tf = TransformedField[ (r^2"Polar" -> a^3/r)"Cartesian", Sin[t]^2f, {r, t} -> {x, y}]

TeXForm @ tf

$\frac{y^2 \left(x^2 \sqrt{x^2+y^2}+y^2 \sqrt{x^2+y^2}-1\right)}{\left(x^2+y^2\right)^{3/2}}$

cValues = {0.00001, 0.01, 0.05, 0.1, 0.3, 0.6, 1.0, 1.5, 2.0, 2.5, 3.2};
a = 1;

ContourPlot[tf, {x, -3, 3}, {y, -3, 3}, 
  Contours -> cValues, 
  PlotPoints-> 200,
  Axes -> True,
  Frame -> False,
  PlotRange -> All, 
  ContourShading -> None, 
  AspectRatio -> Automatic]Automatic,
  RegionFunction -> (Norm[{#, #2}] <= 3&)]

enter image description hereenter image description here

You can also use TransformedField to get a function that can be used as the first argument of ContourPlot:

 tf = TransformedField[ "Polar" -> "Cartesian", 
   (r^2 - a^3/r) Sin[t]^2, {r, t} -> {x, y}]

TeXForm @ tf

$\frac{y^2 \left(x^2 \sqrt{x^2+y^2}+y^2 \sqrt{x^2+y^2}-1\right)}{\left(x^2+y^2\right)^{3/2}}$

cValues = {0.00001, 0.01, 0.05, 0.1, 0.3, 0.6, 1.0, 1.5, 2.0, 2.5, 3.2};
a = 1;

ContourPlot[tf, {x, -3, 3}, {y, -3, 3}, 
  Contours -> cValues, 
  PlotPoints-> 200,
  Axes -> True,
  Frame -> False,
  PlotRange -> All, 
  ContourShading -> None, 
  AspectRatio -> Automatic]

enter image description here

You can also use TransformedField to get a function that can be used as the first argument of ContourPlot:

 f = (r^2 - a^3/r) Sin[t]^2;
 tf = TransformedField[ "Polar" -> "Cartesian", f, {r, t} -> {x, y}]

TeXForm @ tf

$\frac{y^2 \left(x^2 \sqrt{x^2+y^2}+y^2 \sqrt{x^2+y^2}-1\right)}{\left(x^2+y^2\right)^{3/2}}$

cValues = {0.00001, 0.01, 0.05, 0.1, 0.3, 0.6, 1.0, 1.5, 2.0, 2.5, 3.2};
a = 1;

ContourPlot[tf, {x, -3, 3}, {y, -3, 3}, 
  Contours -> cValues, 
  PlotPoints-> 200,
  Axes -> True,
  Frame -> False,
  PlotRange -> All, 
  ContourShading -> None, 
  AspectRatio -> Automatic,
  RegionFunction -> (Norm[{#, #2}] <= 3&)]

enter image description here

added 97 characters in body
Source Link
kglr
  • 400.5k
  • 18
  • 488
  • 929

You can also use TransformedField to get a function that can be used as the first argument of ContourPlot:

 tf = TransformedField[ "Polar" -> "Cartesian", 
   (r^2 - a^3/r) Sin[t]^2, {r, t} -> {x, y}]

TeXForm @ tf

$\frac{y^2 \left(x^2 \sqrt{x^2+y^2}+y^2 \sqrt{x^2+y^2}-1\right)}{\left(x^2+y^2\right)^{3/2}}$

cValues = {0.00001, 0.01, 0.05, 0.1, 0.3, 0.6, 1.0, 1.5, 2.0, 2.5, 3.2};
a = 1;

ContourPlot[Evaluate@
   TransformedField["Polar" -> "Cartesian", 
      (r^2 - a^3/r) Sin[t]^2, 
      {r, t} -> {x, y}]ContourPlot[tf,
  {x, -3, 3}, {y, -3, 3}, 
  Contours -> cValues, 
  PlotPoints-> 200,
  Axes -> True,
  Frame -> False,
  PlotRange -> All, 
  ContourShading -> None, 
  AspectRatio -> Automatic]

enter image description here

You can also use TransformedField to get a function that can be used as the first argument of ContourPlot:

cValues = {0.00001, 0.01, 0.05, 0.1, 0.3, 0.6, 1.0, 1.5, 2.0, 2.5, 3.2};
a = 1;

ContourPlot[Evaluate@
   TransformedField["Polar" -> "Cartesian", 
      (r^2 - a^3/r) Sin[t]^2, 
      {r, t} -> {x, y}],
  {x, -3, 3}, {y, -3, 3}, 
  Contours -> cValues, 
  PlotPoints-> 200,
  Axes -> True,
  Frame -> False,
  PlotRange -> All, 
  ContourShading -> None, 
  AspectRatio -> Automatic]

enter image description here

You can also use TransformedField to get a function that can be used as the first argument of ContourPlot:

 tf = TransformedField[ "Polar" -> "Cartesian", 
   (r^2 - a^3/r) Sin[t]^2, {r, t} -> {x, y}]

TeXForm @ tf

$\frac{y^2 \left(x^2 \sqrt{x^2+y^2}+y^2 \sqrt{x^2+y^2}-1\right)}{\left(x^2+y^2\right)^{3/2}}$

cValues = {0.00001, 0.01, 0.05, 0.1, 0.3, 0.6, 1.0, 1.5, 2.0, 2.5, 3.2};
a = 1;

ContourPlot[tf, {x, -3, 3}, {y, -3, 3}, 
  Contours -> cValues, 
  PlotPoints-> 200,
  Axes -> True,
  Frame -> False,
  PlotRange -> All, 
  ContourShading -> None, 
  AspectRatio -> Automatic]

enter image description here

Source Link
kglr
  • 400.5k
  • 18
  • 488
  • 929
Loading