# Scatter plot vector of (Static)vectors with Plots

**URL:** https://discourse.julialang.org/t/scatter-plot-vector-of-static-vectors-with-plots/64232
**Category:** General Usage
**Tags:** arrays, plots
**Created:** [July 7, 2021, 7:48pm UTC](https://discourse.julialang.org/t/scatter-plot-vector-of-static-vectors-with-plots/64232 "2021-07-07T19:48:33Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)
#### Post date: [July 7, 2021, 7:48pm UTC](https://discourse.julialang.org/t/scatter-plot-vector-of-static-vectors-with-plots/64232/1 "2021-07-07T19:48:33Z")

</div>

Is there a more direct way to plot a vector of vectors as a scatter plot with plots?

```julia
julia> using Plots, StaticArrays

julia> points = rand(SVector{2,Float64},10);

julia> scatter([x[1] for x in points],[x[2] for x in points]) # a cleaner way to do this?

```

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

---

<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 7, 2021, 8:12pm UTC](https://discourse.julialang.org/t/scatter-plot-vector-of-static-vectors-with-plots/64232/2 "2021-07-07T20:12:14Z")

</div>

One option:

```julia
scatter(eachrow(hcat(points...))...)

```

---

<div class="post-metadata">

### Author: ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)
#### Post date: [July 7, 2021, 8:21pm UTC](https://discourse.julialang.org/t/scatter-plot-vector-of-static-vectors-with-plots/64232/3 "2021-07-07T20:21:57Z")

</div>

Maybe

```julia
scatter(first.(x)..., last.(x)...)

```

---

<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 7, 2021, 8:29pm UTC](https://discourse.julialang.org/t/scatter-plot-vector-of-static-vectors-with-plots/64232/4 "2021-07-07T20:29:17Z")

</div>

No need to splat it seems: `scatter(first.(points),last.(points))`

---

<div class="post-metadata">

### Author: ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)
#### Post date: [July 7, 2021, 8:54pm UTC](https://discourse.julialang.org/t/scatter-plot-vector-of-static-vectors-with-plots/64232/5 "2021-07-07T20:54:01Z")

</div>

Of course, those are vectors already! Perils of posting from mobile…

---

<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 7, 2021, 10:15pm UTC](https://discourse.julialang.org/t/scatter-plot-vector-of-static-vectors-with-plots/64232/6 "2021-07-07T22:15:33Z")

</div>

Shorter: `scatter(Tuple.(points))`
