1
$\begingroup$

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.

Plot

plot

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.

enter image description here

$\endgroup$
  • 2
    $\begingroup$ 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. $\endgroup$ – tad Jun 28 at 23:59
  • 2
    $\begingroup$ 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]&] $\endgroup$ – Bob Hanlon Jun 29 at 1:39
  • $\begingroup$ 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. $\endgroup$ – Mark R Jun 29 at 6:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.