# How-to extract a region from a ListContourPlot?

## Question

How could I extract a surface from the ListContourPlot and use it to sample data? Below is the plot, and the code used to generate it. The GridLines define the surface of interest.

Please note, the Outer function used to generate the data is a bit slow.

## Code

ListContourPlot[
(* Data Specification *)
Outer[{#1, #2, #1*#2} &, Subdivide[.01, 1, 100], Subdivide[10^4, 2*10^7, 400]] // Flatten[#, 1] &

(* General Configuration *)
, Frame -> True

, ImageSize -> Medium
, PlotRangeClipping -> False
, ScalingFunctions -> {"Log10", "Log10"}

(* Contour Configuration *)
, Contours -> {500000, 1200000, 2200000}
, ContourShading -> (RGBColor /@ {"#a3d977", "#ffeca9", "#ffdf71" ,"#ff8f80"})
, ContourStyle -> {{Thick, Dashed, Black}}

(* Annotation *)
, PlotLegends -> Placed[Automatic, Below]

(* Region Configuration *)
, GridLinesStyle -> Directive[Black]
, GridLines -> {{.2, .4}, {10^6, 5*10^6}}
]


## Edit 1

Given the comments, I thought I'd try and piece together a visual of what I'd like to achieve. In essence, I want to select a surface between (x1, x2) and (y1,y2) respecting the different color bounds within it. I then want to take a random sample from that surface, see image below.

• By "surface of interest" do you mean the portion of the plot in the rectangle defined by the intersecting grid lines? If "sample data" means plotting values in that region, try an interpolating function of your data. – tad Jun 28 at 23:59
• If what you want is a random point in the region bounded by the gridlines: rgn = ImplicitRegion[0.2 < x < 0.4 && 10^6 < y < 5*^6, {x, y}]; RandomPoint[rgn]; or for 100 points: RandomPoint[rgn, 100]. If instead you want to filter a data set to the defined region: Select[data, Element[#, rgn]&] – Bob Hanlon Jun 29 at 1:39
• Given a triplet of values that feeds the ListContourPlot, you may include the legend and use that as a criteria to select relevant points. For example, say the highest value region in the legend has a value of "x", then Select[someData,#[[-1]]>=x&] will give you the points that are in that region. – Mark R Jun 29 at 6:29