File:Mpl example Mandelbrot set.svg

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search

Original file(SVG file, nominally 900 × 868 pixels, file size: 1.46 MB)

Captions

Captions

Add a one-line explanation of what this file represents

Summary

[edit]
Description
English: The Mandelbrot set, plotted with Python and matplotlib. (Originally programmed for Rosetta Code.)
Date
Source Own work
Author Adrien F. Vincent
SVG development
InfoField
 
The SVG code is valid.
 
This plot was created with Matplotlib.
Source code
InfoField

Python code

##########
## Code for the figure
##########
import matplotlib.pyplot as plt
import numpy as np

from matplotlib.cm import prism as colormap

fig, ax = plt.subplots(figsize=(10, 10))

def m(a):
    z = 0
    for n in range(1, 100):
        z = z**2 + a
        if abs(z) > 2.0:
            return n
    return np.NaN

X = np.arange(-2.0, 0.8, 0.001)
Y = np.arange(-1.5, 1.5, 0.001)
Z = np.zeros((len(Y), len(X)))

for iy, y in enumerate(Y):
    print (iy, "of", len(Y))
    for ix, x in enumerate(X):
        Z[iy,ix] = m(x + 1j * y)

ax.imshow(Z, cmap=colormap, interpolation='none',
          extent=[X.min(), X.max(), Y.min(), Y.max()])

ax.set_xlabel("Re(c)")
ax.set_ylabel("Im(c)")

fig.savefig("mandelbrot_python.svg")
plt.show()
##########

Rationale: this work aims at providing a version of the previous work https://commons.wikimedia.org/wiki/File:Logarithmic_Spiral_Pylab.svg , done by Morn, with a source code that uses object-oriented matplotlib interface and without Python wildcard import.

Licensing

[edit]
I, the copyright holder of this work, hereby publish it under the following license:
w:en:Creative Commons
attribution share alike
This file is licensed under the Creative Commons Attribution-Share Alike 4.0 International license.
You are free:
  • to share – to copy, distribute and transmit the work
  • to remix – to adapt the work
Under the following conditions:
  • attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
  • share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current09:52, 27 September 2016Thumbnail for version as of 09:52, 27 September 2016900 × 868 (1.46 MB)Adrien F. Vincent (talk | contribs)User created page with UploadWizard

There are no pages that use this file.

File usage on other wikis

Metadata