I am trying to exctract contours of specific value (2.6*10^-6) out of a ContourPlot and measure their area.
Below you can see the code. It is noticable that not all of the relevant contours showed in the left plot are shown on the right one as well. Any suggestion of what am I doing wrong?
data = Import["C:\\Users\\doa\\Documents\\private\\school\\PhD\\thesistex\\sigma_limit_difference.xlsx", {"Sheets", "synthetic clusters"}];
data = data[[2 ;; 3002, 2 ;; 3]];
\[ScriptCapitalD] = SmoothKernelDistribution[data, 9.34];
contour = ContourPlot[Evaluate@PDF[\[ScriptCapitalD], {x, y}], {x, 0, 1024}, {y, 0,
1024}, PlotRange -> {Automatic}, PlotPoints -> 50, Contours -> 10, ColorFunction -> "DarkRainbow", AxesStyle -> {30, 20}, ImageSize -> Scaled[0.7]];
contour2 =ContourPlot[Evaluate@PDF[\[ScriptCapitalD], {x, y}], {x, 0, 1024}, {y, 0,
1024}, PlotRange -> {Automatic}, PlotPoints -> 60, Contours -> {2.6*10^-6}, ColorFunction -> "DarkRainbow", AxesStyle -> {30, 20}, ImageSize -> Scaled[0.7],ContourLabels -> True];
{contour, contour2}
I am not sure if there is a need to insert the excel file (in case it is needed please explain how and I will)
thanks in advance
Doron
All thank you very much for the help:
I tried again, this time using some random data so everyone can folow up.
The solution of changing the PlotRange parameter to "All" did'nt solve the problem. It is not just the "White areas" are seen on the left plot with plotrange full, but most impoprtant is whay dont we see them all in the right Plot? Maybe it is related to very small contours?
As for the contour area: Now I get an answer (Thanks...) but still get this warning message:
"NIntegrate::slwcon: Numerical integration converging too slowly; suspect one of the following: singularity, value of the integration is 0, highly oscillatory integrand, or WorkingPrecision too small. >>"
here is the code I am using:
SeedRandom[5]; data = RandomReal[1024, {3000, 2}];
\[ScriptCapitalD] = SmoothKernelDistribution[data, 9.34];
contour = ContourPlot[Evaluate@PDF[\[ScriptCapitalD], {x, y}], {x, 0, 1024}, {y, 0,
1024}, PlotRange -> {All}, PlotPoints -> 50, Contours -> 10, ColorFunction -> "DarkRainbow", AxesStyle -> {30, 20}, ImageSize -> Scaled[0.4]];
contour2 =ContourPlot[Evaluate@PDF[\[ScriptCapitalD], {x, y}], {x, 0, 1024}, {y,0,1024}, PlotRange -> {All}, PlotPoints -> 60, Contours -> {2.52*10^-6}, ColorFunction -> "DarkRainbow", AxesStyle -> {30, 20}, ImageSize -> Scaled[0.4], ContourLabels -> True];
{contour, contour2}
GG = NIntegrate[Boole[PDF[\[ScriptCapitalD], {x, y}] > 11.52*10^-7], {x, 0, 1024}, {y, 0, 1024}]
PlotRange -> All
and see if it looks how you expect. (I'm not sure what looks wrong -- sorry!) $\endgroup$NIntegrate[Boole[PDF[dist, {x, y}] > 2.6*10^-6], {x, 0, 1024}, {y, 0, 1024}]
. You might need to play with the options to get all the areas. $\endgroup$dist
instead of\[ScriptCapitalD]
for the distribution -- did you make the change back to script D? (You can edit the question to add more code/images that help explain the problem/question. That's probably better that putting them in a comment.) $\endgroup$