3
$\begingroup$

I want to make a ListDensityPlot within the region bounded by

ImplicitRegion[
 Abs[x] <= (2 \[Pi])/Sqrt[3] && Abs[-(x/Sqrt[3]) + y] <= (4 \[Pi])/3 &&
   Abs[x/Sqrt[3] + y] <= (4 \[Pi])/3, {x, y}]

The data file "ssf_ud01_249.dat" can be found from the link: https://drive.google.com/file/d/1MU2e2DrzHOkmtMFx-dpGV8NpdC8fD_Gj/view?usp=sharing

amp = Import[
   "ssf_ud01_249.dat", 
   "Table"];
a = ListDensityPlot[amp, Frame -> True, 
   FrameTicksStyle -> Directive[Black, 18], FrameLabel -> {"", ""}, 
   FrameStyle -> 
    Directive[Black, FontSize -> 22, FontFamily -> "Times"], 
   PlotLegends -> Placed[Automatic, Right], 
   LabelStyle -> 
    Directive[Black, FontSize -> 16, FontFamily -> "Times"], 
   ColorFunction -> (ColorData["BlueGreenYellow"][
       Rescale[#, {-0.05, 1.05}]] &), ColorFunctionScaling -> True, 
   PlotRange -> {{(-2 \[Pi])/Sqrt[3], (2 \[Pi])/Sqrt[3]}, {(-4 \[Pi])/
      3, (4 \[Pi])/3}, All}, AspectRatio -> 2/Sqrt[3]];

g2 = Graphics[{Black, Thickness[0.005], 
    Line[{{0, (4 \[Pi])/3}, {-((2 \[Pi])/Sqrt[3]), (2 \[Pi])/
       3}, {-((2 \[Pi])/Sqrt[3]), -((2 \[Pi])/3)}, {0, -((4 \[Pi])/
        3)}, {(2 \[Pi])/Sqrt[3], -((2 \[Pi])/3)}, {(2 \[Pi])/Sqrt[
       3], (2 \[Pi])/3}, {0, (4 \[Pi])/3}}]}];
Show[a, g2]

Can anyone help me in this case? Thank you in advance.

$\endgroup$

1 Answer 1

6
$\begingroup$

Defined a RegionFunction, Function[{x, y}, rm@{x, y} where rm = RegionMember[reg].

Clear[reg,rm];
reg = ImplicitRegion[
   Abs[x] <= (2 π)/Sqrt[3] && 
    Abs[-(x/Sqrt[3]) + y] <= (4 π)/3 && 
    Abs[x/Sqrt[3] + y] <= (4 π)/3, {x, y}];

rm = RegionMember[reg];

ListDensityPlot[amp, Frame -> True, 
 FrameTicksStyle -> Directive[Black, 18], FrameLabel -> {"", ""}, 
 FrameStyle -> 
  Directive[Black, FontSize -> 22, FontFamily -> "Times"], 
 PlotLegends -> Placed[Automatic, Right], 
 LabelStyle -> 
  Directive[Black, FontSize -> 16, FontFamily -> "Times"], 
 ColorFunction -> (ColorData["BlueGreenYellow"][
     Rescale[#, {-0.05, 1.05}]] &), ColorFunctionScaling -> True, 
 PlotRange -> {{(-2 π)/Sqrt[3], (2 π)/Sqrt[3]}, {(-4 π)/
     3, (4 π)/3}, All}, AspectRatio -> 2/Sqrt[3], 
 RegionFunction -> Function[{x, y}, rm@{x, y}]]

enter image description here

$\endgroup$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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