Plotting multiple points at every instance

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.

500-element Array{Array{Float64,1},1}:
 [112.0, 113.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?

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

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.

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

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


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

julia> b = [ [3], [4, 5] ]
2-element Array{Array{Int64,1},1}:
 [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)

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