# How do I plot a matrix in Plots instead of gadfly

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)

`````` 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?

Another way to do this in Gadfly:

``````p = plot(z=(x,y)->Mandelbrot(x+y*im),
xmin=[-2.5], xmax=[1.0], ymin=[-1.75], ymax=[1.75],
Stat.contour(levels=[10:30;], samples=200), Geom.path,
Theme(panel_fill="midnightblue")
)
`````` 1. `Gadfly.spy` is aimed at the quick plotting of numerical matrices e.g. where would expect to see the diagonal here?:
``````using LinearAlgebra
eye = Matrix(I,10,10)