Calling a path without building it, python, pylab inline

I use an outline for the algorithm, but I am only interested in its collection of paths. As I called

pylab inline

from the very beginning, and now it’s too difficult to rewrite the code without the built-in (many functions should be declared more carefully, for example np.something () instead of something (), etc.), I was wondering if there is a way to name the circuit without creating outline map? Sort of

contour(image_matrix, 'No Show')? 

Hi

+4
source share
2 answers

Below is a modified code that I used to get points on a unit circle inside a declared meshgrid. It gives contour points faster than plt.contour and does not build points.

Matplotlib._cntr - , plt.contour, .

import matplotlib._cntr as cntr
import numpy as np

# Test data.
x = np.linspace(-1, 1, 20)
y = np.linspace(-1, 1, 20)

x, y = np.meshgrid(x, y)
z = x**2 + y**2 - 1            # Function to get points from
# the above function can be replaced with any curve equation
# conics like ellipse or hyperbola: ((x**2)/a)+((y**2)/b)-1,etc. 


level = 0
c = cntr.Cntr(x, y, z)
nlist = c.trace(level, level, 0)
segs = nlist[:len(nlist)//2]
print segs[0][0]    # x,y coords of contour points.

, python. , .

: http://matplotlib.1069221.n5.nabble.com/pyplot-Extract-contourset-without-plotting-td15868.html

Mr.Ian Thomas 'contour_test.py', .

: http://matplotlib.1069221.n5.nabble.com/attachment/15872/0/contour_test.py

+2

contour ( ). question, , , , matplotlib._cntr.

pylab, gui, . %pylab qt, cs = contour(image_matrix). plt.show(), cs, .

- matplotlib.interactive(False) .

+1

Source: https://habr.com/ru/post/1589234/


All Articles