from lets_plot import *
LetsPlot.setup_html()
def f(x, y, n):
z = np.sin(x * 3 * np.pi / n)
z += np.sin(y * 3 * np.pi / n)
z += x * 3 / n
z += y * 5 / n
return z
n = 50
x = np.arange(n)
y = np.arange(n)
X, Y = np.meshgrid(x, y)
Z = f(X, Y, n)
data = dict(
x=X.reshape(-1),
y=Y.reshape(-1),
z=Z.reshape(-1))
p = ggplot(data, aes('x','y', z='z')) \
+ theme_void() + ggsize(200, 200)
p + geom_contour(sampling=sampling_vertex_dp(100))