4
$\begingroup$

I have the following data in the format of {x1,y1,z1}:

{{0.05, 0, 2.09412}, {0.1, 0, 2.00505}, {0.15, 0, 1.8692}, {0.2, 0, 
  1.70208}, {0.25, 0, 1.51965}, {0.3, 0, 1.33654}, {0.35, 0, 
  1.16343}, {0.4, 0, 1.01005}, {0.45, 0, 0.883653}, {0.5, 0, 
  0.792333}, {0.6, 0, 0.794668}, {0.65, 0, 1.08459}, {0, -10, 
  2.11716}, {0.05, -10, 2.08704}, {0.1, -10, 2.00062}, {0.15, -10, 
  1.5764}, {0.2, -10, 1.69942}, {0.25, -10, 1.1256}, {0.3, -10, 
  0.915311}, {0.35, -10, 0.724784}, {0.4, -10, 0.557347}, {0.45, -10, 
  0.414329}, {0.5, -10, 0.295847}, {0.55, -10, 0.201322}, {0.6, -10, 
  0.129954}, {0.65, -10, 0.0809156}, {0.7, -10, 
  0.0535506}, {0.75, -10, 0.0474673}, {0, -20, 2.12459}, {0.05, -20, 
  2.01208}, {0.1, -20, 1.84956}, {0.15, -20, 1.81342}, {0.2, -20, 
  1.64175}, {0.25, -20, 1.45434}, {0.3, -20, 1.26322}, {0.35, -20, 
  1.07861}, {0.45, -20, 0.544381}, {0.5, -20, 0.625104}, {0.55, -20, 
  0.335852}, {0.6, -20, 0.265945}, {0.65, -20, 0.218091}, {0.7, -20, 
  0.330485}, {0.75, -20, 0.186575}, {0, -30, 2.12495}, {0.05, -30, 
  2.04312}, {0.1, -30, 1.95586}, {0.15, -30, 1.81408}, {0.2, -30, 
  1.6472}, {0.25, -30, 1.46717}, {0.3, -30, 1.28524}, {0.35, -30, 
  1.11062}, {0.4, -30, 0.949941}, {0.45, -30, 0.807552}, {0.5, -30, 
  0.685852}, {0.55, -30, 0.586033}, {0.6, -30, 0.508438}, {0.65, -30, 
  0.452949}, {0.7, -30, 0.419327}, {0.75, -30, 0.40741}, {0, -40, 
  2.12564}, {0.05, -40, 2.07402}, {0.1, -40, 1.97611}, {0.15, -40, 
  1.80464}, {0.2, -40, 1.68348}, {0.25, -40, 1.51231}, {0.4, -40, 
  1.02099}, {0.45, -40, 0.886038}, {0.5, -40, 0.771047}, {0.55, -40, 
  0.677185}, {0.6, -40, 0.604868}, {0.65, -40, 0.554097}, {0.75, -40, 
  0.51663}, {0, -50, 2.12519}, {0.1, -50, 2.00847}, {0.15, -50, 
  1.88592}, {0.25, -50, 1.57604}, {0.3, -50, 1.41193}, {0.35, -50, 
  1.20883}, {0.4, -50, 1.06172}, {0.45, -50, 0.979901}, {0.5, -50, 
  0.870339}, {0.55, -50, 0.781138}, {0.6, -50, 0.712876}, {0.65, -50, 
  0.665729}, {0.7, -50, 0.639627}, {0.75, -50, 0.603863}, {0, -60, 
  2.12294}, {0.05, -60, 2.11458}, {0.1, -60, 2.06337}, {0.15, -60, 
  1.9396}, {0.2, -60, 1.80301}, {0.25, -60, 1.65146}, {0.3, -60, 
  1.49609}, {0.35, -60, 1.34578}, {0.4, -60, 1.20679}, {0.45, -60, 
  1.08345}, {0.5, -60, 0.978466}, {0.55, -60, 0.893153}, {0.6, -60, 
  0.828311}, {0.65, -60, 0.766473}, {0.75, -60, 0.757909}, {0, -70, 
  2.1163}, {0.1, -70, 2.09201}, {0.15, -70, 1.99933}, {0.25, -70, 
  1.73465}, {0.3, -70, 1.58807}, {0.35, -70, 1.44493}, {0.4, -70, 
  1.31189}, {0.45, -70, 1.19181}, {0.5, -70, 1.09252}, {0.55, -70, 
  1.01063}, {0.65, -70, 0.906969}, {0.7, -70, 0.885735}, {0.75, -70, 
  0.885036}, {0, -80, 2.11109}, {0.05, -80, 2.16128}, {0.1, -80, 
  2.13834}, {0.15, -80, 2.06322}, {0.2, -80, 1.95322}, {0.25, -80, 
  1.82325}, {0.3, -80, 1.68531}, {0.35, -80, 1.54924}, {0.4, -80, 
  1.4219}, {0.45, -80, 1.30806}, {0.5, -80, 1.2108}, {0.55, -80, 
  1.13193}, {0.6, -80, 1.07251}, {0.65, -80, 1.03302}, {0.7, -80, 
  1.01374}, {0.75, -80, 1.01484}, {0, -90, 2.1012}, {0.1, -90, 
  2.18573}, {0.15, -90, 2.12946}, {0.2, -90, 2.03395}, {0.25, -90, 
  1.91529}, {0.3, -90, 1.78634}, {0.35, -90, 1.65728}, {0.4, -90, 
  1.53539}, {0.45, -90, 1.44954}, {0.5, -90, 1.33206}, {0.55, -90, 
  1.256}, {0.6, -90, 1.19888}, {0.65, -90, 1.16138}, {0.7, -90, 
  1.1439}, {0.75, -90, 1.14658}, {0, -100, 2.08892}, {0.05, -100, 
  2.21053}, {0.1, -100, 2.23328}, {0.15, -100, 2.19699}, {0.2, -100, 
  2.11682}, {0.25, -100, 2.0099}, {0.3, -100, 1.93021}, {0.35, -100, 
  1.76802}, {0.55, -100, 1.38212}, {0.6, -100, 1.32714}, {0.65, -100, 
  1.29147}, {0.7, -100, 1.27558}, {0.75, -100, 1.27976}, {0, -110, 
  2.07483}, {0.05, -110, 2.22384}, {0.1, -110, 2.29696}, {0.15, -110, 
  2.26525}, {0.2, -110, 2.20105}, {0.25, -110, 2.10633}, {0.3, -110, 
  1.99567}, {0.35, -110, 1.88055}, {0.4, -110, 1.76944}, {0.45, -110, 
  1.70653}, {0.5, -110, 1.58073}, {0.55, -110, 1.50977}, {0.6, -110, 
  1.45684}, {0.65, -110, 1.4229}, {0.7, -110, 1.40855}, {0.75, -110, 
  1.41406}, {0, -120, 2.05932}, {0.05, -120, 2.24053}, {0.1, -120, 
  2.32622}, {0.15, -120, 2.33349}, {0.2, -120, 2.28603}, {0.25, -120, 
  2.20381}, {0.3, -120, 2.15022}, {0.4, -120, 1.88875}, {0.45, -120, 
  1.7915}, {0.5, -120, 1.70719}, {0.55, -120, 1.63861}, {0.6, -120, 
  1.58767}, {0.7, -120, 1.54239}, {0.75, -120, 1.54925}, {0, -130, 
  2.04175}, {0.05, -130, 2.25467}, {0.1, -130, 2.37059}, {0.15, -130, 
  2.4013}, {0.25, -130, 2.30201}, {0.3, -130, 2.2105}, {0.35, -130, 
  2.10961}, {0.4, -130, 2.0092}, {0.45, -130, 1.9159}, {0.5, -130, 
  1.83461}, {0.55, -130, 1.7684}, {0.6, -130, 1.71929}, {0.65, -130, 
  1.68857}, {0.7, -130, 1.67701}, {0.75, -130, 1.68508}, {0, -140, 
  2.02214}, {0.05, -140, 2.26615}, {0.1, -140, 2.41313}, {0.15, -140, 
  2.46827}, {0.2, -140, 2.45649}, {0.25, -140, 2.40065}, {0.3, -140, 
  2.31894}, {0.4, -140, 2.13038}, {0.45, -140, 2.04116}, {0.5, -140, 
  1.96286}, {0.55, -140, 1.8989}, {0.6, -140, 1.85167}, {0.65, -140, 
  1.82245}, {0.7, -140, 1.81224}, {0.75, -140, 1.8215}, {0, -150, 
  2.00046}, {0.05, -150, 2.27555}, {0.1, -150, 2.45351}, {0.15, -150, 
  2.53417}, {0.25, -150, 2.49932}, {0.3, -150, 2.42779}, {0.35, -150, 
  2.39361}, {0.4, -150, 2.25218}, {0.45, -150, 2.16694}, {0.5, -150, 
  2.09159}, {0.55, -150, 2.03005}, {0.6, -150, 1.98459}, {0.65, -150, 
  1.95688}, {0.7, -150, 1.94792}, {0.75, -150, 1.95841}, {0, -160, 
  1.97679}, {0.05, -160, 2.28305}, {0.1, -160, 2.49248}, {0.15, -160, 
  2.59871}, {0.2, -160, 2.62551}, {0.25, -160, 2.59793}, {0.3, -160, 
  2.53685}, {0.35, -160, 2.45838}, {0.4, -160, 2.37431}, {0.5, -160, 
  2.2209}, {0.55, -160, 2.16152}, {0.6, -160, 2.1179}, {0.65, -160, 
  2.09163}, {0.7, -160, 2.08399}, {0, -170, 1.95107}, {0.05, -170, 
  2.28874}, {0.1, -170, 2.52693}, {0.15, -170, 2.66171}, {0.2, -170, 
  2.70897}, {0.25, -170, 2.69625}, {0.3, -170, 2.64592}, {0.35, -170, 
  2.57521}, {0.4, -170, 2.49675}, {0.45, -170, 2.41973}, {0.5, -170, 
  2.35045}, {0.55, -170, 2.29341}, {0.65, -170, 2.22678}, {0.7, -170, 
  2.22043}, {0.75, -170, 2.23318}, {0, -180, 1.92335}, {0.05, -180, 
  2.29265}, {0.1, -180, 2.55992}, {0.15, -180, 2.72297}, {0.2, -180, 
  2.7915}, {0.25, -180, 2.79413}, {0.3, -180, 2.75487}, {0.35, -180, 
  2.69217}, {0.4, -180, 2.61944}, {0.45, -180, 2.54656}, {0.5, -180, 
  2.4804}, {0.55, -180, 2.47704}, {0.6, -180, 2.38554}, {0.65, -180, 
  2.3622}, {0.75, -180, 2.37093}, {0, -190, 1.89362}, {0.05, -190, 
  2.29474}, {0.15, -190, 2.78236}, {0.25, -190, 2.89155}, {0.3, -190, 
  2.86372}, {0.35, -190, 2.80908}, {0.4, -190, 2.74222}, {0.5, -190, 
  2.61049}, {0.55, -190, 2.55803}, {0.65, -190, 2.49787}, {0.7, -190, 
  2.49395}, {0.75, -190, 2.55036}}


I would like to plot a density plot with 2 distinct colours, one for the region with $z<2.2$, and one for the region with $z>2.2$.

Something like this, where the green region refers to points with values greater than 2.2. and the red region refers to points with values smaller than 2.2

enter image description here

Is it possible to achieve a similar effect with discrete points? Thank you.

$\endgroup$

1 Answer 1

5
$\begingroup$

ListContourPlot

ListContourPlot[data, Contours -> {2.2},
 ContourStyle -> Directive[Thick, Black], 
 ContourShading -> {Red, Green}]

enter image description here

Interpolation + ContourPlot

iF = Interpolation[{{#, #2}, #3} & @@@ data, InterpolationOrder -> 1];

ContourPlot[iF[x, y], {x, 0, 1}, {y, -200, 0}, 
 Contours -> {2.2}, 
 ContourStyle -> Directive[Thick, Black], 
 ContourShading -> {Red, Green}]

enter image description here

Interpolation + RegionPlot

RegionPlot[{iF[x, y] <= 2.2, iF[x, y] >= 2.2}, {x, 0, 1}, {y, -200, 0}]

enter image description here

$\endgroup$
1
  • $\begingroup$ @bobthelegend, my pleasure. $\endgroup$
    – kglr
    Jan 5, 2021 at 8:00

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.