# Makie user defined marker example?

**URL:** https://discourse.julialang.org/t/makie-user-defined-marker-example/24346
**Category:** Visualization
**Created:** [May 18, 2019, 7:18am UTC](https://discourse.julialang.org/t/makie-user-defined-marker-example/24346 "2019-05-18T07:18:43Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![LaurentPlagne](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/laurentplagne/32/10103_2.png) [@LaurentPlagne](https://discourse.julialang.org/u/LaurentPlagne)
#### Post date: [May 18, 2019, 7:18am UTC](https://discourse.julialang.org/t/makie-user-defined-marker-example/24346/1 "2019-05-18T07:18:43Z")

</div>

Hi,

It try to set up an animation for colliding polygons with Makie.

It is OK if a use poly! and pass new polygon coordinates at each time steps but I guess that it would be more efficient If I use scatter! with user defined polygonal markers, and provide translations and rotations at each timesteps…

Any hint ?

![anim-opt](https://global.discourse-cdn.com/julialang/original/3X/0/f/0fbdb847e10269abd08ddd279d29fd33d36fc8e4.gif)

---

<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: [May 19, 2019, 3:43pm UTC](https://discourse.julialang.org/t/makie-user-defined-marker-example/24346/2 "2019-05-19T15:43:57Z")

</div>

You can plot multiple polys in one go, and then just update the whole poly array each frame, which should be fairly efficient:

```julia

p1 = decompose(Point2f0, Circle(Point2f0(0), 1f0))
p2 = Point2f0[(0, 0), (0, 1), (1, 1), (1, 0)]
polys = map(1:10) do i
    p = (p1, p2)[rand(1:2)]
    off = (rand(Point2f0) .* 5)
    size = rand()
    map(p) do point
        off .+ (point .* size)
    end
end
poly(polys, scale_plot = false, color = rand(RGBf0, 10))

```

You can also rotate/scale/translate any plot:

```nohighlight

scene = Scene()
poly_plots = map(polys) do poly
    poly!(poly, color = rand(RGBf0), scale_plot = false)[end]
end
display(scene)
rotate!(poly_plots[1], 0.5)
translate!(poly_plots[1], 0.0, 0.1, 0.0).

```

The above could be more efficient then updating the whole poly array - depends a bit on how many points you have per poly.

This would be the most efficient, but would require that each polygon you want has a unicode representation:

```nohighlight

vals = rand(10)
positions = rand(Point2f0, 10)
markers = [('◀', '■', '⬣', '⬤')[rand(1:4)] for i in 1:10]
scatter(positions, color = vals, rotations = vals, marker = markers)

```

It’s also a bit unprecise, but I think if you supply markersizes, it should be scalable to the correct size

---

<div class="post-metadata">

### Author: ![LaurentPlagne](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/laurentplagne/32/10103_2.png) [@LaurentPlagne](https://discourse.julialang.org/u/LaurentPlagne)
#### Post date: [May 19, 2019, 4:38pm UTC](https://discourse.julialang.org/t/makie-user-defined-marker-example/24346/3 "2019-05-19T16:38:31Z")

</div>

Thanks a lot !  
I have to study your snippet. I still have some difficulties with the `do` construct 😉

I already use the scatter form for the circle thus I wonder if I could define my own marker. I understand now that it must have a unicode representation.
