Mandelbrot set: Difference between revisions
→Mercator zooms of the Mandelbrot set using NumPy: Explanations have been added and the zoom depth has been doubled. In addition, the escape time is compressed as described by David Madore in order to improve the image quality.
(→Mercator zooms of the Mandelbrot set using NumPy: for avoiding cropping the mercator map and for nice looking pictures) |
(→Mercator zooms of the Mandelbrot set using NumPy: Explanations have been added and the zoom depth has been doubled. In addition, the escape time is compressed as described by David Madore in order to improve the image quality.) |
||
Line 7,151:
import matplotlib.pyplot as plt
d, h =
n, r = 50, 2.5 # number of iterations and escape radius (r > 2)
Line 7,157:
y = np.linspace(0, 2 / d * h, h, endpoint=False)
C = (-0.4 + 0.6 * 1j) + 1.5 *
A, B = C.real, C.imag
Line 7,171:
T[M] = k + 1
fig, ax = plt.subplots(figsize=(
ax.imshow(T, cmap=plt.cm.twilight_shifted, vmin=0
plt.savefig("
D = 2 / d # distance between points in the grid
S = (150 * D) ** 2 #
fig, ax = plt.subplots(figsize=(
ax.scatter(A, B, s=S, c=T, cmap=plt.cm.twilight_shifted, vmin=0
plt.savefig("Mandelbrot_plot.png", dpi=100)</lang>
A small change in the code above allows Mercator zooms of the Mandelbrot set (
<lang python>import numpy as np
import matplotlib.pyplot as plt
d, h =
n, r =
x = np.linspace(0, 2 * np.pi, d, endpoint=False)
y = np.linspace(0, 2 * np.pi / d * h, h, endpoint=False)
C = (-0.
A, B = C.real, C.imag
Line 7,205:
T[M] = k + 1
fig, ax = plt.subplots(figsize=(
ax.imshow(T, cmap=plt.cm.twilight_shifted, vmin=0
plt.savefig("Mercator_map.png", dpi=100)
D = 2 * np.pi / d * abs(
S = (150 * D) ** 2 #
t = T ** 0.5 # compression of the escape times with a concave function
fig, ax = plt.subplots(2, 2, figsize=(16, 16))▼
ax[0, 0].scatter(A[0:200], B[0:200], s=S[0:200], c=T[0:200], cmap=plt.cm.twilight_shifted, vmin=0, vmax=n)▼
ax[0, 1].scatter(A[100:300], B[100:300], s=S[0:200], c=T[100:300], cmap=plt.cm.twilight_shifted, vmin=0, vmax=n)▼
ax[
ax[
▲ax[
plt.savefig("Mandelbrot_zoom.png", dpi=100)</lang>▼
▲ax[
=={{header|R}}==
|