# contour plot (cartesian) using spherical coordinates postions

Let´s say that I have a data in the following configuration: { Lat, Long,distance, energy}-> lat, long -> galactic coordinates, distance unit - parsecs (3.2 ly) energy unit- ergs.

I need to plot them as a contourplot like that

(figure1):

The steps:

The original array: dat1.dat

{{lat, long, distance, energy},....}


Then I transformed lat, long , in cartesian coordinates, so the list has now 2 cartesian coordinates and energy as third element( "z" is the energy value) :

$dat1 = Import["/home/.............../dat1.dat"] mapdados3={#[[3]]*1000 *Cos[#[[1]]* Pi/180]*Cos[#[[2]]* Pi/180], #[[3]]*1000*Cos[#[[1]]* Pi/180] *Sin[#[[2]]* Pi/180], #[[3]]} & /@$dat1


Note: I did the multiplication for 1000, just for scale issues.

I did a plot like the frame of figure 1 (not yet the contours , ok?):

ListPlot[mapdados3[[All, {1,2}]], FrameLabel -> {"Long Galactic", "Long Galactic"},
Frame -> True, FrameTicks -> {{{{0, 180 \[Degree]}}, {{0, 0 \[Degree]}}},
{{{0, 270 \[Degree]}}, {{0, 90 \[Degree]}}} } ]


figure 2:

Each curve in figure 1 is a decade ranging from 10^34 to 10^36 ergs/[100pc^2].

I did a contour plot for testing (it was terrible!!):

ListContourPlot[mapdados3, DataRange -> All, InterpolationOrder -> 3, Mesh -> 100]


figure 3:

My question is: How Do I include the ploting data in a listcontourplot , using the frame of figure 1 and 2 and taking in account the range from 10^34 to 10^36 ergs? Why is my contour so wrong?

UPDATE: 1

 ListContourPlot[mapdados3, ContourShading -> None, InterpolationOrder -> 2]


Figure 4

UPDATE2:

Some improvements:

a. first I did a new cartesian plotting.

marker1 = Graphics[{Lighter[Blue, 0.1], Disk[]}];
ListPlot[mapdados3[[All, {1, 2}]], PlotMarkers -> {marker1, .006},
PlotRange -> {{-3000, 3000}, {-3000, 3000}},
FrameLabel -> {"Long Galactic", "Long Galactic"}, Frame -> True,
AspectRatio -> 1,
GridLines -> {Table[i, {i, -3000, 3000, 100}],
Table[i, {i, -3000, 3000, 100}]},
FrameTicks -> {{{{0, 180 \[Degree]}}, {{0, 0 \[Degree]}}},
{{{0, 270 \[Degree]}}, {{0,
90 \[Degree]}}}}, Ticks -> {{0, 1000, 2000}, {0, 1000, 2000}}
]


Figure 5

b. A new contour plot changing the scales, but not so good. It seems that the contour lines is taking points very far awy, is there a way to rule that only point closer than xxx units, could be considered to do a certain contour?

ListContourPlot[mapdados3, ContourShading -> None,
PlotRange -> {{-3000, 3000}, {-3000, 3000}},
Contours -> {10^34, 10^35, 10^36, 10^37, 10^38},
InterpolationOrder -> 5, AspectRatio -> 3/4]


Figure 6

UPDATE 3.

I used maxPlotPoints, reducing the range of axis scale:

   mapdados4 =
DeleteCases[
a >= 3000 || a <= -3000 || p >= 3000 || p <= -3000, Infinity]


figure 7:

UPDATE 3: finally!

I did a contour map, 'similar" figure 1, but the distances points far away are connected.

this is the code:

 $tudo =data mapdados3Obs = Sort[{#[[8]] *Cos[#[[7]]* Pi/180]*Cos[#[[6]]* Pi/180], #[[8]]*Cos[#[[7]]* Pi/180] *Sin[#[[6]]* Pi/180], #[[4]]} & /@$tudo];

Show[ListContourPlot[mapdados3Obs, PlotRange -> {5*10^34, 2*10^37}, PerformanceGoal -> "Quality", ContourShading -> None, InterpolationOrder -> 1,(*PlotLegends->Automatic,*)ContourStyle -> Blue, MaxPlotPoints -> 200, Contours -> Function[{min, max}, Range[min, max, (max - min)/17]], FrameLabel -> {{None, None}, {" long galactica (\[Degree])", Style[" 10 Contornos", 12, "Panel"]}}, ImageSize -> Medium, Frame -> True,
FrameTicks -> {{{0, 18 \[Degree]}, { 0, 0 \[Degree]}}, {{0, 27 \[Degree]}, {0, 90 \[Degree]}}}], ListPlot[{{0, 0}}, PlotMarkers -> {
{Graphics[{Yellow, Disk[{0, 0}, 1]}], 0.008}}]]


and the contour:

• Thanks bbgodfrey, My firefox had some bug that did not allow me use the math code formatting. – locometro Jun 26 '15 at 11:04
• I'm having trouble with the download, but try removing DataRange -> All from the final plot. I think that's confusing ListContourPlot. – rcollyer Jun 26 '15 at 17:49
• Hi I did some progress, removing datarange, and contourshading -None. Please see the update 1 – locometro Jun 27 '15 at 3:42
• Make that dat1[[All, {2, 1, 3}]] to get latitude and longitude in their correct spots. – rcollyer Jun 29 '15 at 21:01
• @locometro Two problems: 1/ mapdados3 contains a point whose x coordinate is about 20000, so it is >>> than the rest of the x's. You can see that if you run ListPlot[mapdados3[[All, {1, 2}]], PlotRange -> All]. 2/ What exactly do you want to show/interpolate with the ContourPlot ? I mean look at the energy ("z") distribution here : ListPointPlot3D[mapdados3] ... – SquareOne Jun 30 '15 at 14:20