File:Julia set, plotted with Matplotlib.svg

From testwiki
Jump to navigation Jump to search
    Original file (SVG file, nominally 900 × 630 pixels, file size: 5.11 MB)

    This file is from Wikimedia Commons and may be used by other projects. The description on its file description page there is shown below.

    Summary

    Description
    English: The Julia set plotted with Matplotlib. The seed coordinates are (-0.512511498387847167, 0.521295573094847167), the same as for File:Julia set (red).png.
    Date
    Source Own work
    Author Morn
    SVG development
    InfoField
     The SVG code is valid.
     This plot was created with Matplotlib.
    Source code
    InfoField

    Python code

    Source code
    from pylab import *
    from numpy import NaN
    from matplotlib.colors import LogNorm
    
    # seed parameter from https://commons.wikimedia.org/wiki/File:Julia_set_%28red%29.png
    s = -0.512511498387847167, 0.521295573094847167
    
    res = .001    # grid resolution
    max_it = 1000 # maximum number of iterations
    
    figure(figsize = (10, 7))
    
    def jul(a):
    	z = a
    	for n in range(1, max_it + 1):
    		z = z**2 + s[0] + 1j * s[1]
    		if abs(z) > 2:
    			return n
    	return NaN
    
    X = arange(-2, 2 + res, res)
    Y = arange(-1.5,  1.5 + res, res)
    Z = zeros((len(Y), len(X)))
    
    for iy, y in enumerate(Y):
    	print (iy + 1, "of", len(Y))
    	for ix, x in enumerate(X):
    		Z[-iy - 1, ix] = jul(x + 1j * y)
    
    save("julia", Z)	# save array to file
    
    imshow(Z, cmap = plt.cm.viridis, interpolation = 'none', norm = LogNorm(),
      extent = (X.min(), X.max(), Y.min(), Y.max()))
    xlabel("Re(z)")
    ylabel("Im(z)")
    axis((-1.5, 1.5, -1, 1))
    savefig("julia_python.svg")
    show()
    

    Licensing

    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.

    Captions

    A Julia set

    Items portrayed in this file

    depicts

    20 January 2019

    5,357,367 byte

    630 pixel

    900 pixel

    image/svg+xml

    cc50ac6f00a8b0fbe41d5da5198861cbfaca1f53

    File history

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

    Date/TimeThumbnailDimensionsUserComment
    current23:09, 20 January 2019Thumbnail for version as of 23:09, 20 January 2019900 × 630 (5.11 MB)wikimediacommons>MornUser created page with UploadWizard

    There are no pages that use this file.