Quantcast
Channel: First steps - JuliaLang
Viewing all articles
Browse latest Browse all 2795

How do I plot a matrix in Plots instead of gadfly

$
0
0

@StevenSiew wrote:

My attempt at producing an image of the Mandelbrot set

using Gadfly

const ImageWidth = 30
const ImageHeight = 30
const IterationLimit = 100

function Mandelbrot(c)::Int64
    seed = 0.0 + 0.0im
    z = seed^2 + c
    for count = 1:IterationLimit
        if abs(z) > 2.0
            return count
        end
        z = z^2 + c
    end
    return 0
end

function MandelbrotArray(Xstart::Float64,Xlen::Float64,Ystart::Float64,Ylen::Float64)
    matrix = Array{Int64}(undef,ImageWidth,ImageHeight)
    Xdelta = Xlen / ( ImageWidth - 1 )
    Ydelta = Ylen / ( ImageHeight - 1 )
    for y = 1:ImageHeight , x = 1:ImageWidth
        Xvalue = Xstart + (x - 1) * Xdelta
        Yvalue = Ystart + (y - 1) * Ydelta
        matrix[x,y] = Mandelbrot(Xvalue + Yvalue * im)
    end
    return matrix
end

img = MandelbrotArray(-2.5,3.5,-1.75,3.5)
Gadfly.spy(img)

27%20AM

I have two questions:

  1. How do I plot a matrix using Plots instead of Gadfly

  2. Why is the image of the Mandelbrot set vertical (pointing upwards) instead of lying on it’s side like all other images of Mandelbrot set on the web?

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 2795

Latest Images

Trending Articles



Latest Images