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

**URL:** https://discourse.julialang.org/t/how-do-i-plot-a-matrix-in-plots-instead-of-gadfly/29801
**Category:** New to Julia
**Created:** [October 12, 2019, 12:14am UTC](https://discourse.julialang.org/t/how-do-i-plot-a-matrix-in-plots-instead-of-gadfly/29801 "2019-10-12T00:14:33Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![StevenSiew](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevensiew/32/218393_2.png) [@StevenSiew](https://discourse.julialang.org/u/StevenSiew)
#### Post date: [October 12, 2019, 12:14am UTC](https://discourse.julialang.org/t/how-do-i-plot-a-matrix-in-plots-instead-of-gadfly/29801/1 "2019-10-12T00:14:33Z")

</div>

My attempt at producing an image of the Mandelbrot set

```julia
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](https://global.discourse-cdn.com/julialang/original/3X/d/8/d89f96fb22a86f5e2c21d1efd43cef41b3be7133.png)

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?

---

<div class="post-metadata">

### Author: ![Mattriks](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mattriks/32/351_2.png) [@Mattriks](https://discourse.julialang.org/u/Mattriks)
#### Post date: [October 12, 2019, 3:06am UTC](https://discourse.julialang.org/t/how-do-i-plot-a-matrix-in-plots-instead-of-gadfly/29801/2 "2019-10-12T03:06:42Z")

</div>

Another way to do this in Gadfly:

```julia
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")
)

```

![Mandelbrot](https://global.discourse-cdn.com/julialang/original/3X/3/6/36dd79d86894fbd7bc9c4a26efef2a5a8a3cbba0.png)

1. `Gadfly.spy` is aimed at the quick plotting of numerical matrices e.g. where would expect to see the diagonal here?:

```julia
using LinearAlgebra
eye = Matrix(I,10,10)
Gadfly.spy(eye)

```
