Plotting multiple points at every instance

plotting
#1

I am trying to plot the results of my Monte-Carlo simulation. I have data of the following form, where each row corresponds to a one-time instance.

b1
500-element Array{Array{Float64,1},1}:
 [115.0]       
 [112.0, 113.0]
 [112.0]       
 [104.0]       
 [111.0]       
 [112.0]       
 ⋮             
 [116.0]       
 [100.0]       
 [106.0]       
 [107.0, 108.0]

When I do scatter(1:1:500,b1), I get the following error

attempt to access 1-element Array{Float64,1} at index [2]

What is a good way to fix this?

#2

You need b1 to be a vector of numbers. The easiest way of doing that is reduce(vcat, b1)

#3

If I did that, I get an array of numbers and would loose pertinent information at a particular time instant. For example, b[2]=[1,2] would just become entries in the array. I want the plot to convey that at t=2, there are two values.

#4

You need to duplicate the time information so that you have (x, y) pairs with the same number of xs and ys.

#5

But to flatten the nested array is turning out to be hard for me.

#6

E.g.

julia> t = [1, 2]
2-element Array{Int64,1}:
 1
 2

julia> b = [ [3], [4, 5] ]
2-element Array{Array{Int64,1},1}:
 [3]
 [4, 5]

julia> collect(Iterators.flatten([ [ (tt, x) for x in bb ] for (tt, bb) in zip(t, b) ]))
3-element Array{Tuple{Int64,Int64},1}:
 (1, 3)
 (2, 4)
 (2, 5)
#7

But it’s easier just to spit out the information in this format when you first create the data.