0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Julia集合を描画するpython script

Posted at

Julia集合でも見て、ちょっと休憩。

julia.py
import numpy as np
import matplotlib.pyplot as plt

def julia_set(h, w, max_iter):
    y, x = np.ogrid[-1.4:1.4:h*1j, -2:2:w*1j]
    c = -0.7 + 0.27j
    z = x + y*1j
    divtime = max_iter + np.zeros(z.shape, dtype=int)

    for i in range(max_iter):
        z = z**2 + c
        diverge = z*np.conj(z) > 2**2
        div_now = diverge & (divtime == max_iter)
        divtime[div_now] = i
        z[diverge] = 2

    return divtime

h, w = 1000, 1500
max_iter = 100

plt.figure(figsize=(12, 8))
plt.imshow(julia_set(h, w, max_iter), cmap='gist_earth', extent=[-2, 2, -1.4, 1.4])
plt.colorbar()
plt.title('Julia Set')
plt.xlabel('Re(z)')
plt.ylabel('Im(z)')
plt.tight_layout()
plt.show()

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?