6
$\begingroup$

I have data like this

f[r,theta]

and cells number are about 600*600 (uniform mesh)

The original data has the property of uniform mesh for r and theta. However, when I transfer them into Cartesian coordinates, this property disappeared and it became a 360,000-point data. Using ListDensityPlot was very slow.

Because I have to plot a lot of data of this kind, I wonder if there is any other methods to plot them in polar coordinates with higher efficient.

$\endgroup$
  • $\begingroup$ 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! $\endgroup$ – Dr. belisarius Nov 4 '15 at 14:22
  • $\begingroup$ Take a look at MaxPlotPoints $\endgroup$ – Dr. belisarius Nov 4 '15 at 14:25
9
$\begingroup$

How about you make a ListDensityPlot as usual in the original polar coordinates and then transform the vertices to Cartesian coordinates.

data = Flatten[
   Table[{r, θ, Sin[3 r] Cos[3 θ]}, {r, 0, 2 π, 2 π/100}, {θ, 0, 2 π, 2 π/100}], 1];
plot = ListDensityPlot[data]

enter image description here

transformGraphicsComplex[f_, g_] := 
 GraphicsComplex[f /@ First[g], Sequence @@ Rest[g]]
Graphics[transformGraphicsComplex[# /. {r_, θ_} :> {r Cos[θ], r Sin[θ]} &, First@plot]]

enter image description here

$\endgroup$
5
$\begingroup$

If the following is reasonable or not depends on your points' geometry. Anyway:

(*generate the points (slow)*)
n = 600;
f[r_, t_] := r^2 Sin[6 t]
s = CoordinateTransform[ "Cylindrical" -> "Cartesian", {{r1, t1, f[r1, t1]}}];
tab = Table[ Flatten[s /. {r1 -> r, t1 -> t}, 1], {r, n}, {t, 0, 2 Pi, 2 Pi/n}];

(*plot them(fast) *)
ListPlot3D[Flatten[RandomSample[tab, 10], 1]]

Mathematica graphics

$\endgroup$
  • $\begingroup$ I don't get defining s in terms of r1, t1 and then using Rule to replace r1 with r and t1 with t. Wouldn't s = CoordinateTransform[ "Cylindrical" -> "Cartesian", {{r, t, f[r, t]}}] work directly? $\endgroup$ – Jack LaVigne Nov 4 '15 at 15:35
  • $\begingroup$ @JackLaVigne Yes, but this way is more clear to me. $\endgroup$ – Dr. belisarius Nov 4 '15 at 15:45
2
$\begingroup$

using Rahul's data

f = Interpolation[{#[[1 ;; 2]], #[[3]]} & /@ data];
DensityPlot[
 f[Norm[{x, y}], Pi + ArcTan[-x, y] ] , {x, -2 Pi, 2 Pi}, {y, -2 Pi, 
  2 Pi},
 RegionFunction -> (Norm[{##}] < 2 Pi &), PlotPoints -> 100]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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