Contour level at arbitrary (x,y)

4 visualizaciones (últimos 30 días)
Chad Greene
Chad Greene el 11 de Jun. de 2013
With a contour plot I can use the Data Cursor to click on an (x,y) point and get the Level at that point.
Can I get these Levels from the command line, given an arbitrary (x,y)? I know I can regrid or interpolate the zdata set, but I'd like to extract the values that are plotted, not interpolated values.
Thanks!

Respuestas (1)

Walter Roberson
Walter Roberson el 11 de Jun. de 2013
Set distinct colors for each level. Display. Frame capture. Determine mapping between x/y coordinates and pixels. Now, for each (x,y) pair to be query, map into the captured frame, extract the color, and do a reverse lookup based on the color to determine which contour level corresponds to that color.
  2 comentarios
Chad Greene
Chad Greene el 12 de Jun. de 2013
Interesting idea, Walter. I'll have to think of an efficient way to implement your suggestion. My only concern is that the (x,y) points of pixels corresponding to any lines between patches, or any text, or any tick marks or legends would return an incorrect or undefined Level value.
The only other solution I could think of was to use inpolygon with the patch vertices. This seems to work for some patches, but not others. I haven't determined exactly why some patches are problem causers.
Walter Roberson
Walter Roberson el 12 de Jun. de 2013
The polygons generated by contouring are not clean polygons surrounding each contour level. Instead, each edge is drawn just once as part of some polygon. Mostly the uppermost (smallest) contour gets done as a single polygon, but mostly anything else ends out not being explicitly constructed.

Iniciar sesión para comentar.

Categorías

Más información sobre Contour Plots en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by