3
$\begingroup$

I'm trying to plot polar coordinates, that is to plot surfaces of constant parameters $r$ and $\theta$. Which are related to the cartesian ones by $$ x = r \sin \theta\\ y = r \cos \theta $$ One way is to use countor plot as

Show[ContourPlot[ Evaluate@Table[x^2 + y^2 == a^2, {a, 1, 6}], {x, -5, 5}, {y, -5, 5},ContourStyle -> Directive[Dashed, Gray]], ContourPlot[Evaluate@Table[y == Tan[a] x, {a, 0,\[Pi], 1/\[Pi]}], {x, -5, 5}, {y, -5, 5}, ContourStyle -> Directive[Dashed, Gray]]] 

which results in

enter image description here

This is not bad but there are some problem around the $\{0,0\}$ point and I'm also struggling to nicely devide the angle by the radial lines.

Another options is

ParametricPlot[{r Cos[t], r Sin[t]}, {t, 0, 2 \[Pi]}, {r, 0, 3}, Mesh -> Automatic] 

which results in

enter image description here

This is a much nicer graph, but I am not able to remove the colour and I am also lacking control with the Mesh.

Is there a simpler way to do this? Note that I am aware that we can do this manually by Graphics and Line functions, but I want to plot other, more complicated coordinates where this would no be an options.

$\endgroup$

3 Answers 3

4
$\begingroup$
ParametricPlot[{r Cos[t], r Sin[t]}, {t, 0, 2 \[Pi]}, {r, 0, 3}, Mesh -> Automatic, PlotStyle -> None]; 

enter image description here

ParametricPlot[{r Cos[t], r Sin[t]}, {t, 0, 2 \[Pi]}, {r, 0, 3}, Mesh -> 4, PlotStyle -> None] 

enter image description here

Trying to answer your comment

ParametricPlot[{r Cos[t], r Sin[t]}, {t, 0, 2 \[Pi]}, {r, 0, 3}, Mesh -> {Subdivide[0, 2 Pi, 12], Subdivide[0, 2 Pi, 12]}, PlotStyle -> None] 

enter image description here

By changing one or both Subdivide - parameters, MeshStyle or BoundaryStyle you have full control:

ParametricPlot[{r Cos[t], r Sin[t]}, {t, 0, 2 \[Pi]}, {r, 0, 3}, Mesh -> {Subdivide[0, 2 Pi, 12], Subdivide[0, 2 Pi, 4]}, BoundaryStyle -> {Red, Thickness[0.005], Dashed}, MeshStyle -> Dashed, PlotStyle -> None] 

enter image description here

$\endgroup$
1
  • $\begingroup$ Is there a way to have more control over Mesh lines? For example I would like to divide the circle equally by having a radial line at each π/6 radians. That is to have 12 radial lines but at the same time make sure that one line coincides with the y-axis. $\endgroup$ Commented Oct 7, 2023 at 9:02
5
$\begingroup$

Using PolarPlot:

n = 6; PolarPlot[{ n}, {θ, 0, 2 π} , PolarAxes -> {False, False} , PlotRange -> {{-n, n}, {-n, n}} , PlotStyle -> None , PolarGridLines -> {Range[0, 2 π, π/6], Range[1, n]} , GridLinesStyle -> {{Gray, Dashed}, {Gray, Dashed}} , PolarTicks -> {Range[0, 2 π - π/6, π/6], Range[1, n, 1]} , PlotRangePadding -> Scaled[.05] , Frame -> True , Axes -> False , Epilog -> {FaceForm[White], EdgeForm[Gray] , Disk[{0, 0}, 0.15]} ] 

enter image description here

You can experiment with the PolarAxes options and adjust PlotRangePadding as required.

$\endgroup$
4
$\begingroup$

You may prescibe Mesh for both coordinates and an adopted Array of Colors

 ParametricPlot[{r Cos[t], r Sin[t]}, {t, 0, 2 \[Pi]}, {r, 0, 3}, Mesh -> {5, 7}, MeshShading -> RandomColor[ RGBColor[ _, _, 0.2], {5, 7}]] 

regular randomly painted mesh

The mesh can be given explitely in coordinates

 ParametricPlot[{r Cos[t], r Sin[t]}, {t, 0, 2 \[Pi]}, {r, 0, 3}, Mesh -> {RandomReal[{0, 2 \[Pi]}, 5], RandomReal[{1, 3}, 7]}, MeshShading -> RandomColor[ Hue[ _, 0.7, 0.8], {5, 7}]] 

randomly meshed

$\endgroup$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.