Home > Software engineering >  How can I get Isocontour's xy coordinates for contour plot?
How can I get Isocontour's xy coordinates for contour plot?

Time:04-13

I am trying to get isosurface's x-y coordinates from 3D plot. Here is my attempt;

import matplotlib.pyplot as plt

from numpy import pi, cos, sin, linspace, meshgrid

x = linspace(0,50,1000)
y = linspace(0,50,1000)

n = 5
L = 50
t = 0

def gyroid(x, y, n, L, t):
    tanım1 = (sin(2*pi*n*x/L) * cos(2*pi*n*y/L)   sin(2*pi*n*y/L)   cos(2*pi*n*x/L))
    return tanım1*tanım1 - t**2

XX, YY = meshgrid(x, y)
z = gyroid(XX, YY, n, L, t)

thickness = 0.1
contour = plt.contour(XX, YY, z,levels=[thickness])
# Attempt to get x-y coordinates
dat0= contour.allsegs[0][0]
plt.plot(dat0[:,0],dat0[:,1])

The gyroid function is normally looks like; enter image description here

  • Related