# Makie - Makie crashes

**URL:** <https://discourse.julialang.org/t/makie-makie-crashes/64569>\
**Category:** Visualization\
**Tags:** makie\
**Created:** [July 13, 2021, 1:26pm UTC](https://discourse.julialang.org/t/makie-makie-crashes/64569 "2021-07-13T13:26:40Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![stroebel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stroebel/32/6774_2.png) [@stroebel](https://discourse.julialang.org/u/stroebel)\
**Post date:** [July 13, 2021, 1:26pm UTC](https://discourse.julialang.org/t/makie-makie-crashes/64569/1 "2021-07-13T13:26:40Z")

</div>

I am trying to explore using Makie for some interactive applications and I have a hurdle that I am not sure how to get over. When following the tutorial for [Schelling’s Segregation model](https://juliadynamics.github.io/Agents.jl/stable/examples/schelling/) on the Agents.jl page, Makie just creates a blank screen and then vanishes (picture attached). I am not sure how to debug the problem.

I am running Ubuntu 20.04 LTS with Julia 1.6.0.

 ![image](https://global.discourse-cdn.com/julialang/original/3X/e/2/e298ddca5525d02a46758fa4ee80e2f6e4d2c2a3.png)

### Code

```julia-auto
using Agents
using Random
using Statistics:mean
using InteractiveDynamics
using GLMakie

mutable struct SchellingAgent <: AbstractAgent
    id::Int
    pos::NTuple{2,Int}
    mood::Bool
    group::Int
end

function initialise(; numagents=320, griddims=(20, 20), min_to_be_happy=3, seed=125)
    space = GridSpace(griddims, periodic=false)
    properties = Dict(:min_to_be_happy => min_to_be_happy)
    rng = Random.MersenneTwister(seed)
    model = ABM(
        SchellingAgent, space;
        properties, rng, scheduler=Schedulers.randomly
    )

    for n in 1:numagents
        agent = SchellingAgent(n, (1, 1), false, n < numagents / 2 ? 1 : 2)
        add_agent_single!(agent, model)
    end
    return model

end

function agent_step!(agent, model)
    minhappy = model.min_to_be_happy
    count_neighbours_same_group = 0
    
    for neighbour in nearby_agents(agent, model)
        if agent.group == neighbour.group
            count_neighbours_same_group += 1
        end
    end
    
    if count_neighbours_same_group >= minhappy
        agent.mood = true
    else
        move_agent_single!(agent, model)
    end
    return

end

x(agent) = agent.pos[1]
groupcolor(a) = a.group == 1 ? :blue : :orange
groupmarker(a) = a.group == 1 ? :circle : :rect 

parange = Dict(:min_to_be_happy => 0:8)
adata = [(:mood, sum), (x, mean)]
alabels = ["happy", "avg. x"]

model = initialise(; numagents=300)

figure, adf, mdf = abm_data_exploration(
    model, agent_step!, dummystep, parange;
    ac=groupcolor, am=groupmarker, as=10, 
    adata, alabels
)

```

---

<div class="post-metadata">

**Author:** ![sdanisch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdanisch/32/1406_2.png) [@sdanisch](https://discourse.julialang.org/u/sdanisch)\
**Post date:** [July 14, 2021, 8:47am UTC](https://discourse.julialang.org/t/makie-makie-crashes/64569/2 "2021-07-14T08:47:45Z")

</div>

I can’t reproduce that… How did you run the code?  
You could try `display(figure)`, which may give you at least a stacktrace…

---

<div class="post-metadata">

**Author:** ![stroebel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stroebel/32/6774_2.png) [@stroebel](https://discourse.julialang.org/u/stroebel)\
**Post date:** [July 14, 2021, 9:16am UTC](https://discourse.julialang.org/t/makie-makie-crashes/64569/3 "2021-07-14T09:16:01Z")

</div>

Hey sandisch,

I just run it with `julia schelling.jl`.

I added your suggestion, but it did not output anything. It had the same result.

---

<div class="post-metadata">

**Author:** ![sdanisch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdanisch/32/1406_2.png) [@sdanisch](https://discourse.julialang.org/u/sdanisch)\
**Post date:** [July 14, 2021, 9:23am UTC](https://discourse.julialang.org/t/makie-makie-crashes/64569/4 "2021-07-14T09:23:50Z")

</div>

Ahhh, I see 😃  
The display loop isn’t blocking by default, since most people run code in the repl or vscode, to work on things interactively.  
So if you run `julia schelling.jl`, it will just quit as soon as the script run through.  
I recommend working with the REPL / VSCode (simplest form would be to start the julia repl and run `include("schelling.jl")`).  
If you _really_ must run this as a script, you can do `wait(display(figure))`.

---

<div class="post-metadata">

**Author:** ![stroebel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stroebel/32/6774_2.png) [@stroebel](https://discourse.julialang.org/u/stroebel)\
**Post date:** [July 14, 2021, 9:27am UTC](https://discourse.julialang.org/t/makie-makie-crashes/64569/5 "2021-07-14T09:27:54Z")

</div>

Thank you kindly
