Mandelbrot set: Difference between revisions
Content added Content deleted
m (→{{header|Python}}: Minor change (save picture)) |
(→{{header|Python}}: a more mathematical spelling, as the students are used to it.) |
||
Line 6,394: | Line 6,394: | ||
import matplotlib.pyplot as plt |
import matplotlib.pyplot as plt |
||
n = 50 # number of iterations |
|||
dots = 100 |
|||
⚫ | |||
iterations = 50 |
|||
x = np.linspace(-2. |
x = np.linspace(-2.5, 1.5, 401) |
||
y = np.linspace(-1. |
y = np.linspace(-1.5, 1.5, 301) |
||
A, B = np.meshgrid(x, y) |
A, B = np.meshgrid(x, y) |
||
⚫ | |||
⚫ | |||
Z = np.zeros_like(C) |
Z = np.zeros_like(C) |
||
⚫ | |||
M = abs(Z) < r |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
M = abs(Z) < r |
|||
T[M] = k + 1 |
|||
⚫ | |||
⚫ | |||
not_escaped = abs(Z) < escape_radius |
|||
escape_table[not_escaped] = i + 1 |
|||
plt.imshow( |
plt.imshow(T, cmap=plt.cm.twilight_shifted) |
||
plt.savefig( |
plt.savefig('image.png', dpi=200)</lang> |
||
=={{header|R}}== |
=={{header|R}}== |