1
$\begingroup$

I plot a figure using ListDensityPlot. Where As shown in the figure, there is no data in the marked rigion. But why is it still shown? How to fix that?

The code used here is

datadensity = Import["datadensity.csv"];
pdensity = 
 ListDensityPlot[datadensity, PlotRange -> All, 
  FrameLabel -> {Row[{Style["\[Epsilon]", 12], 
      Style["\!\(\*SubscriptBox[\(T\), \(2\)]\)", 12]}], 
    Row[{Style["\[Alpha]", 12], 
      Style["/\!\(\*SubscriptBox[\(\[Alpha]\), \(c\)]\)", 12]}]}, 
  FrameStyle -> Directive[12, Black]]

I don't know how to attach the whole data, so the sparse one is shown in the below. This may be useful. Sorry about that. Thank you so much.

datadensity ={{0.001, 1.4901, 1.}, {0.001, 1.9901, 1.}, {0.001, 2.4901, 
  1.}, {0.001, 2.9901, 1.}, {0.001, 3.4901, 1.}, {0.001, 3.9901, 
  1.}, {0.001, 4.4901, 1.}, {0.001, 4.9901, 1.}, {0.001, 5.4901, 
  1.}, {0.001, 5.9901, 1.}, {0.001, 6.4901, 1.}, {0.001, 6.9901, 
  1.}, {0.001, 7.4901, 1.}, {0.001, 7.9901, 1.}, {0.501, 1.4901, 
  1.}, {0.501, 1.9901, 1.}, {0.501, 2.4901, 1.}, {0.501, 2.9901, 
  1.}, {0.501, 3.4901, 1.}, {0.501, 3.9901, 1.}, {0.501, 4.4901, 
  1.}, {0.501, 4.9901, 1.}, {0.501, 5.4901, 1.}, {0.501, 5.9901, 
  1.}, {0.501, 6.4901, 1.}, {0.501, 6.9901, 1.}, {0.501, 7.4901, 
  1.}, {0.501, 7.9901, 1.}, {1.001, 1.4901, 1.}, {1.001, 1.9901, 
  1.}, {1.001, 2.4901, 1.}, {1.001, 2.9901, 1.}, {1.001, 3.4901, 
  1.}, {1.001, 3.9901, 1.}, {1.001, 4.4901, 1.}, {1.001, 4.9901, 
  1.}, {1.001, 5.4901, 1.}, {1.001, 5.9901, 1.}, {1.001, 6.4901, 
  1.}, {1.001, 6.9901, 1.}, {1.001, 7.4901, 1.}, {1.001, 7.9901, 
  1.}, {1.501, 1.4901, 1.}, {1.501, 1.9901, 1.}, {1.501, 2.4901, 
  1.}, {1.501, 2.9901, 1.}, {1.501, 3.4901, 1.}, {1.501, 3.9901, 
  1.}, {1.501, 4.4901, 1.}, {1.501, 4.9901, 1.}, {1.501, 5.4901, 
  1.}, {1.501, 5.9901, 1.}, {1.501, 6.4901, 1.}, {1.501, 6.9901, 
  1.}, {1.501, 7.4901, 1.}, {1.501, 7.9901, 1.}, {2.001, 1.4901, 
  1.00001}, {2.001, 1.9901, 1.00001}, {2.001, 2.4901, 
  1.00001}, {2.001, 2.9901, 1.00001}, {2.001, 3.4901, 
  1.00001}, {2.001, 3.9901, 1.00001}, {2.001, 4.4901, 
  1.00001}, {2.001, 4.9901, 1.00001}, {2.001, 5.4901, 
  1.00001}, {2.001, 5.9901, 1.00001}, {2.001, 6.4901, 
  1.00001}, {2.001, 6.9901, 1.00001}, {2.001, 7.4901, 
  1.00001}, {2.001, 7.9901, 1.00001}, {2.501, 1.4901, 
  1.00003}, {2.501, 1.9901, 1.00002}, {2.501, 2.4901, 
  1.00002}, {2.501, 2.9901, 1.00002}, {2.501, 3.4901, 
  1.00002}, {2.501, 3.9901, 1.00002}, {2.501, 4.4901, 
  1.00002}, {2.501, 4.9901, 1.00002}, {2.501, 5.4901, 
  1.00002}, {2.501, 5.9901, 1.00002}, {2.501, 6.4901, 
  1.00002}, {2.501, 6.9901, 1.00002}, {2.501, 7.4901, 
  1.00002}, {2.501, 7.9901, 1.00002}, {3.001, 1.9901, 
  1.00004}, {3.001, 2.4901, 1.00004}, {3.001, 2.9901, 
  1.00004}, {3.001, 3.4901, 1.00004}, {3.001, 3.9901, 
  1.00004}, {3.001, 4.4901, 1.00004}, {3.001, 4.9901, 
  1.00004}, {3.001, 5.4901, 1.00004}, {3.001, 5.9901, 
  1.00004}, {3.001, 6.4901, 1.00004}, {3.001, 6.9901, 
  1.00004}, {3.001, 7.4901, 1.00004}, {3.001, 7.9901, 
  1.00004}, {3.501, 1.9901, 1.00008}, {3.501, 2.4901, 
  1.00007}, {3.501, 2.9901, 1.00007}, {3.501, 3.4901, 
  1.00007}, {3.501, 3.9901, 1.00006}, {3.501, 4.4901, 
  1.00006}, {3.501, 4.9901, 1.00006}, {3.501, 5.4901, 
  1.00006}, {3.501, 5.9901, 1.00006}, {3.501, 6.4901, 
  1.00006}, {3.501, 6.9901, 1.00006}, {3.501, 7.4901, 
  1.00006}, {3.501, 7.9901, 1.00006}, {4.001, 1.9901, 
  1.00012}, {4.001, 2.4901, 1.00012}, {4.001, 2.9901, 
  1.00011}, {4.001, 3.4901, 1.00011}, {4.001, 3.9901, 1.0001}, {4.001,
   4.4901, 1.0001}, {4.001, 4.9901, 1.0001}, {4.001, 5.4901, 
  1.0001}, {4.001, 5.9901, 1.00009}, {4.001, 6.4901, 1.00009}, {4.001,
   6.9901, 1.00009}, {4.001, 7.4901, 1.00009}, {4.001, 7.9901, 
  1.00009}, {4.501, 1.9901, 1.00019}, {4.501, 2.4901, 
  1.00017}, {4.501, 2.9901, 1.00017}, {4.501, 3.4901, 
  1.00016}, {4.501, 3.9901, 1.00015}, {4.501, 4.4901, 
  1.00015}, {4.501, 4.9901, 1.00015}, {4.501, 5.4901, 
  1.00014}, {4.501, 5.9901, 1.00014}, {4.501, 6.4901, 
  1.00014}, {4.501, 6.9901, 1.00014}, {4.501, 7.4901, 
  1.00013}, {4.501, 7.9901, 1.00013}, {5.001, 2.4901, 
  1.00025}, {5.001, 2.9901, 1.00024}, {5.001, 3.4901, 
  1.00023}, {5.001, 3.9901, 1.00022}, {5.001, 4.4901, 
  1.00022}, {5.001, 4.9901, 1.00021}, {5.001, 5.4901, 
  1.00021}, {5.001, 5.9901, 1.0002}, {5.001, 6.4901, 1.0002}, {5.001, 
  6.9901, 1.00019}, {5.001, 7.4901, 1.00019}, {5.001, 7.9901, 
  1.00019}, {5.501, 2.4901, 1.00035}, {5.501, 2.9901, 
  1.00034}, {5.501, 3.4901, 1.00032}, {5.501, 3.9901, 
  1.00031}, {5.501, 4.4901, 1.0003}, {5.501, 4.9901, 1.00029}, {5.501,
   5.4901, 1.00029}, {5.501, 5.9901, 1.00028}, {5.501, 6.4901, 
  1.00027}, {5.501, 6.9901, 1.00027}, {5.501, 7.4901, 
  1.00026}, {5.501, 7.9901, 1.00026}, {6.001, 2.4901, 
  1.00048}, {6.001, 2.9901, 1.00045}, {6.001, 3.4901, 
  1.00044}, {6.001, 3.9901, 1.00042}, {6.001, 4.4901, 
  1.00041}, {6.001, 4.9901, 1.0004}, {6.001, 5.4901, 1.00039}, {6.001,
   5.9901, 1.00038}, {6.001, 6.4901, 1.00037}, {6.001, 6.9901, 
  1.00036}, {6.001, 7.4901, 1.00036}, {6.001, 7.9901, 
  1.00035}, {6.501, 2.9901, 1.0006}, {6.501, 3.4901, 1.00057}, {6.501,
   3.9901, 1.00055}, {6.501, 4.4901, 1.00054}, {6.501, 4.9901, 
  1.00052}, {6.501, 5.4901, 1.00051}, {6.501, 5.9901, 1.0005}, {6.501,
   6.4901, 1.00049}, {6.501, 6.9901, 1.00048}, {6.501, 7.4901, 
  1.00047}, {6.501, 7.9901, 1.00046}, {7.001, 2.9901, 
  1.00077}, {7.001, 3.4901, 1.00074}, {7.001, 3.9901, 
  1.00071}, {7.001, 4.4901, 1.00069}, {7.001, 4.9901, 
  1.00067}, {7.001, 5.4901, 1.00065}, {7.001, 5.9901, 
  1.00064}, {7.001, 6.4901, 1.00063}, {7.001, 6.9901, 
  1.00062}, {7.001, 7.4901, 1.0006}, {7.001, 7.9901, 1.00059}, {7.501,
   2.9901, 1.00096}, {7.501, 3.4901, 1.00092}, {7.501, 3.9901, 
  1.00089}, {7.501, 4.4901, 1.00087}, {7.501, 4.9901, 
  1.00085}, {7.501, 5.4901, 1.00083}, {7.501, 5.9901, 
  1.00081}, {7.501, 6.4901, 1.00079}, {7.501, 6.9901, 
  1.00078}, {7.501, 7.4901, 1.00076}, {7.501, 7.9901, 
  1.00075}, {8.001, 2.9901, 1.00117}, {8.001, 3.4901, 
  1.00114}, {8.001, 3.9901, 1.0011}, {8.001, 4.4901, 1.00107}, {8.001,
   4.9901, 1.00104}, {8.001, 5.4901, 1.00102}, {8.001, 5.9901, 
  1.001}, {8.001, 6.4901, 1.00098}, {8.001, 6.9901, 1.00096}, {8.001, 
  7.4901, 1.00095}, {8.001, 7.9901, 1.00093}, {8.501, 2.9901, 
  1.00141}, {8.501, 3.4901, 1.00137}, {8.501, 3.9901, 
  1.00133}, {8.501, 4.4901, 1.0013}, {8.501, 4.9901, 1.00127}, {8.501,
   5.4901, 1.00124}, {8.501, 5.9901, 1.00121}, {8.501, 6.4901, 
  1.00119}, {8.501, 6.9901, 1.00117}, {8.501, 7.4901, 
  1.00115}, {8.501, 7.9901, 1.00113}, {9.001, 3.4901, 
  1.00162}, {9.001, 3.9901, 1.00158}, {9.001, 4.4901, 
  1.00154}, {9.001, 4.9901, 1.00151}, {9.001, 5.4901, 
  1.00148}, {9.001, 5.9901, 1.00145}, {9.001, 6.4901, 
  1.00142}, {9.001, 6.9901, 1.0014}, {9.001, 7.4901, 1.00138}, {9.001,
   7.9901, 1.00136}, {9.501, 3.4901, 1.00189}, {9.501, 3.9901, 
  1.00185}, {9.501, 4.4901, 1.00181}, {9.501, 4.9901, 
  1.00177}, {9.501, 5.4901, 1.00174}, {9.501, 5.9901, 
  1.00171}, {9.501, 6.4901, 1.00168}, {9.501, 6.9901, 
  1.00165}, {9.501, 7.4901, 1.00163}, {9.501, 7.9901, 
  1.00161}, {10.001, 3.4901, 1.00218}, {10.001, 3.9901, 
  1.00213}, {10.001, 4.4901, 1.00209}, {10.001, 4.9901, 
  1.00205}, {10.001, 5.4901, 1.00201}, {10.001, 5.9901, 
  1.00198}, {10.001, 6.4901, 1.00195}, {10.001, 6.9901, 
  1.00192}, {10.001, 7.4901, 1.00189}, {10.001, 7.9901, 
  1.00187}, {10.501, 3.4901, 1.00247}, {10.501, 3.9901, 
  1.00243}, {10.501, 4.4901, 1.00238}, {10.501, 4.9901, 
  1.00234}, {10.501, 5.4901, 1.0023}, {10.501, 5.9901, 
  1.00227}, {10.501, 6.4901, 1.00223}, {10.501, 6.9901, 
  1.0022}, {10.501, 7.4901, 1.00218}, {10.501, 7.9901, 
  1.00215}, {11.001, 3.4901, 1.00278}, {11.001, 3.9901, 
  1.00273}, {11.001, 4.4901, 1.00268}, {11.001, 4.9901, 
  1.00264}, {11.001, 5.4901, 1.0026}, {11.001, 5.9901, 
  1.00257}, {11.001, 6.4901, 1.00253}, {11.001, 6.9901, 
  1.0025}, {11.001, 7.4901, 1.00247}, {11.001, 7.9901, 
  1.00244}, {11.501, 3.4901, 1.0031}, {11.501, 3.9901, 
  1.00304}, {11.501, 4.4901, 1.003}, {11.501, 4.9901, 
  1.00295}, {11.501, 5.4901, 1.00291}, {11.501, 5.9901, 
  1.00287}, {11.501, 6.4901, 1.00284}, {11.501, 6.9901, 
  1.00281}, {11.501, 7.4901, 1.00278}, {11.501, 7.9901, 
  1.00275}, {12.001, 3.4901, 1.00342}, {12.001, 3.9901, 
  1.00336}, {12.001, 4.4901, 1.00331}, {12.001, 4.9901, 
  1.00327}, {12.001, 5.4901, 1.00323}, {12.001, 5.9901, 
  1.00319}, {12.001, 6.4901, 1.00315}, {12.001, 6.9901, 
  1.00312}, {12.001, 7.4901, 1.00309}, {12.001, 7.9901, 
  1.00306}, {12.501, 3.4901, 1.00374}, {12.501, 3.9901, 
  1.00369}, {12.501, 4.4901, 1.00364}, {12.501, 4.9901, 
  1.00359}, {12.501, 5.4901, 1.00355}, {12.501, 5.9901, 
  1.00351}, {12.501, 6.4901, 1.00347}, {12.501, 6.9901, 
  1.00344}, {12.501, 7.4901, 1.00341}, {12.501, 7.9901, 1.00338}}

plot

$\endgroup$
4
  • $\begingroup$ Have you tried adding PlotRange -> All? $\endgroup$ Jul 21 at 12:46
  • $\begingroup$ @J.M. Yes, but it is not useful. $\endgroup$
    – so_sure
    Jul 21 at 12:46
  • $\begingroup$ Using InterpolationOrder -> 0 it somehow works, but I don't know why. Waiting for better answers. $\endgroup$
    – H. Zhou
    Jul 21 at 13:31
  • $\begingroup$ I have tried that. It does not work. Thank you. @H.Zhou $\endgroup$
    – so_sure
    Jul 21 at 13:41

1 Answer 1

3
$\begingroup$

This is an extended comment rather than an answer.

$Version

(* "13.1.0 for Mac OS X x86 (64-bit) (June 16, 2022)" *)

ListDensityPlot appears to cover the convex hull of the data points.

Show[
 ListDensityPlot[
  datadensity],
 ListPlot[
  Most /@ datadensity,
  PlotStyle -> Red]]

enter image description here

Defining a region (reg) that excludes the portions of the convex hull that do not contain data points.

Show[
 Region[
  reg = RegionUnion @@
    (ConvexHullRegion /@
      (Flatten[#, 1] & /@
        Partition[
         SplitBy[Most /@ datadensity,
          First], 2, 1])),
  Axes -> True],
 ListPlot[
  Most /@ datadensity,
  PlotStyle -> Red],
 AxesOrigin -> {0, 1}]

enter image description here

However, using reg to define the RegionFunction doesn't change the ListDensityPlot

Show[
 ListDensityPlot[
  datadensity,
  RegionFunction -> Function[{x, y, f}, {x, y} \[Element] reg]],
 ListPlot[
  Most /@ datadensity,
  PlotStyle -> Red]]

enter image description here

Similarly,

Show[
 ListDensityPlot[
  datadensity,
  RegionFunction -> Function[{x, y, f}, RegionMember[reg, {x, y}]]],
 ListPlot[
  Most /@ datadensity,
  PlotStyle -> Red]]
(* same plot *)
$\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.