# Scattergram

**URL:** https://discourse.julialang.org/t/scattergram/36162
**Category:** New to Julia
**Created:** [March 18, 2020, 9:39pm UTC](https://discourse.julialang.org/t/scattergram/36162 "2020-03-18T21:39:26Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![erlebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/erlebach/32/12973_2.png) [@erlebach](https://discourse.julialang.org/u/erlebach)
#### Post date: [March 18, 2020, 9:39pm UTC](https://discourse.julialang.org/t/scattergram/36162/1 "2020-03-18T21:39:26Z")

</div>

I am making a simple scatterplot:

```julia
using Plots
        tk = [1,2,3,5,8]
	y = [1. for i in 1:length(tk)]
	pl = scatter(tk, y, title="Poisson train tk")
	display(pl)

```

This works. However, I feel that there has to be a more Julian way of accomplishing this task. The comprehension list seems like an unnecessary expense, especially if tk if very large. Thanks.

---

<div class="post-metadata">

### Author: ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)
#### Post date: [March 18, 2020, 9:52pm UTC](https://discourse.julialang.org/t/scattergram/36162/2 "2020-03-18T21:52:10Z")

</div>

FWIW, constructing that list will always take negligible time compared to running the plotting.

---

<div class="post-metadata">

### Author: ![BLI](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bli/32/37206_2.png) [@BLI](https://discourse.julialang.org/u/BLI)
#### Post date: [March 18, 2020, 10:02pm UTC](https://discourse.julialang.org/t/scattergram/36162/3 "2020-03-18T22:02:27Z")

</div>

The comprehension list… it is not quite clear to me why you would make `y` be equal to `1.` for all values of `tk`, but if that is what you want, here are some other ways:

```julia
tk = [1,2,3,5,8]
#y = [1. for i in 1:length(tk)]
#y = ones(length(tk))
function f(t)
    return 1.
end
#pl = scatter(tk, y, title="Poisson train tk")
pl = scatter(tk,f,title="Poisson train tk")

```

---

<div class="post-metadata">

### Author: ![erlebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/erlebach/32/12973_2.png) [@erlebach](https://discourse.julialang.org/u/erlebach)
#### Post date: [March 18, 2020, 10:18pm UTC](https://discourse.julialang.org/t/scattergram/36162/4 "2020-03-18T22:18:14Z")

</div>

Good point. I could use a lambda function (anonymous function). The following works:

```
pl = scatter(tk, x->1, title="Poisson train tk")

```

What I really wanted is a set of points along a horizontal axis at a fixed value of y to clearly see the sequence tk.

If you have another good way of displaying this, I am interested to know what it is. Thanks for the answer!

Gordon
