Skip to content

Instantly share code, notes, and snippets.

@ilim0t
Created May 10, 2019 17:16
Show Gist options
  • Select an option

  • Save ilim0t/cedaafa41ca7afb61bd165f12c03009d to your computer and use it in GitHub Desktop.

Select an option

Save ilim0t/cedaafa41ca7afb61bd165f12c03009d to your computer and use it in GitHub Desktop.
import matplotlib.pyplot as plt
import numpy as np
# 各座標に対して0となった点をつないで線にする
delta = 0.025 # 点の間隔
# x, y座標
xrange = np.arange(-2, 2, delta)
yrange = np.arange(-2, 2, delta)
# (N, N)のx, y座標を記した行列
X, Y = np.meshgrid(xrange, yrange)
# 軸の描画範囲 設定
plt.axis([-1, 1, -1, 1])
plt.gca().set_aspect('equal', adjustable='box')
# 描画
Z = np.abs(X) ** (2 / 3) + np.abs(Y) ** (2 / 3) - 1 # ここでの計算は各要素ごと
plt.contour(X, Y, Z, [0])
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment