# How to Plot Fractals using Plots and GR()?

**URL:** <https://discourse.julialang.org/t/how-to-plot-fractals-using-plots-and-gr/85054>\
**Category:** General Usage\
**Tags:** fractal, plots\
**Created:** [July 31, 2022, 10:50am UTC](https://discourse.julialang.org/t/how-to-plot-fractals-using-plots-and-gr/85054 "2022-07-31T10:50:50Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Freya\_the\_Goddess](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/freya_the_goddess/32/36835_2.png) [@Freya\_the\_Goddess](https://discourse.julialang.org/u/Freya_the_Goddess)\
**Post date:** [July 31, 2022, 10:50am UTC](https://discourse.julialang.org/t/how-to-plot-fractals-using-plots-and-gr/85054/1 "2022-07-31T10:50:50Z")

</div>

Hi all,

I have tried this code here:

[https://gist.github.com/XerxesZorgon/5205facbb7c7ef02999e27ead70a5d59](https://gist.github.com/XerxesZorgon/5205facbb7c7ef02999e27ead70a5d59)

But I can’t plot it, I am using Jupyter Notebook and Julia REPL it only shows : ` plotJulia`

 ![Capture d’écran_2022-07-31_17-47-02](https://global.discourse-cdn.com/julialang/original/3X/b/f/bff03508733b6ab14c5b425d713f21a9cc42ee9e.png)

---

<div class="post-metadata">

**Author:** ![cormullion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cormullion/32/49131_2.png) [@cormullion](https://discourse.julialang.org/u/cormullion)\
**Post date:** [July 31, 2022, 12:38pm UTC](https://discourse.julialang.org/t/how-to-plot-fractals-using-plots-and-gr/85054/2 "2022-07-31T12:38:58Z")

</div>

Did you, er, forget to run the function you’ve defined? 🙂

 ![Screenshot 2022-07-31 at 13.37.49](https://global.discourse-cdn.com/julialang/original/3X/9/8/98161342337d5e837a4b646547ef85d4997f03f7.png)

---

<div class="post-metadata">

**Author:** ![Freya\_the\_Goddess](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/freya_the_goddess/32/36835_2.png) [@Freya\_the\_Goddess](https://discourse.julialang.org/u/Freya_the_Goddess)\
**Post date:** [July 31, 2022, 12:47pm UTC](https://discourse.julialang.org/t/how-to-plot-fractals-using-plots-and-gr/85054/3 "2022-07-31T12:47:51Z")

</div>

Wow, so that’s how to plot.

I am just learning Plots and GLMakie, I have no idea till now… it is not forget, but do not know how…

---

<div class="post-metadata">

**Author:** ![empet](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/empet/32/221303_2.png) [@empet](https://discourse.julialang.org/u/empet)\
**Post date:** [July 31, 2022, 1:20pm UTC](https://discourse.julialang.org/t/how-to-plot-fractals-using-plots-and-gr/85054/4 "2022-07-31T13:20:46Z")

</div>

Define your function as follows

```julia
function plotJulia(c::Complex{T}; 
       xRng = [-1.5,1.5], yRng = [-1.5, 1.5], maxIters=100) where T<:Real
  ...
  #maxIters =1000 #comment out this line
  ...      
  #display(heatmap(iterCounts')) #comment out this line, too    
end

```

and call it as:

```julia
itc= plotJulia( -0.04 - 0.6841im; maxIters=125) 
heatmap(itc', c = :matter, size=(400, 300)) 

```

and then replace `maxIters=125`, by `maxIters=500` and look at colorbars of the two heatmaps. You can deduce that the fractal set corresponds to points that leave the disk of radius 2 in about 100-120 iterations. Hence the number  
of iterations must be reduced, because  
with 1000 iterations the interval [100, 120] is mapped on lighter colors within the range [1, 1000], and the fractal is poorly visible.  
125 iterations:  
 ![Julia-set125](https://global.discourse-cdn.com/julialang/original/3X/9/0/903bd38703a7e01a6ebacfb573a68dbc8f276a7c.png)

500 iterations:  
 ![Julia-set500](https://global.discourse-cdn.com/julialang/original/3X/7/c/7c943a5d40b0de9ed8c13dfc01bae56e8937a883.png)

---

<div class="post-metadata">

**Author:** ![Freya\_the\_Goddess](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/freya_the_goddess/32/36835_2.png) [@Freya\_the\_Goddess](https://discourse.julialang.org/u/Freya_the_Goddess)\
**Post date:** [July 31, 2022, 1:37pm UTC](https://discourse.julialang.org/t/how-to-plot-fractals-using-plots-and-gr/85054/5 "2022-07-31T13:37:18Z")

</div>

That’s amazingly beautiful.

Can we make a video of fractals or zoom in of the fractals?

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [July 31, 2022, 3:54pm UTC](https://discourse.julialang.org/t/how-to-plot-fractals-using-plots-and-gr/85054/6 "2022-07-31T15:54:24Z")

</div>

> [@Freya\_the\_Goddess](#):
>
> Can we make a video of fractals or zoom in of the fractals?

See a [beautiful example here](https://i.postimg.cc/xTwtRBwM/mand.gif) and [code here](https://discourse.julialang.org/t/seven-lines-of-julia-examples-sought/50416/47) by @federicostra.
