# Plots.jl how to create a heat map from several curves

So I have about 100 different curves and I’d like to create a heatmap from them. These curves each represent possible solutions to a differential equation and I’d like to create a sort of density plot from them so that in every point in time I can have a 2D smooth kernel histogram. I append an example I made in python. It was done creating a histogram at every point in time but it was really slow and not too visually appealing  Any help will be greatly appreciated!

EDIT: To be more clear. I generate a 100 parameters “p” to a differential equation y’ = f(t, p)and integrate using those parameters and the same set of initial conditions to generate 100 solutions. What I’d like is a plot where t is on the horizontal axis, y on the vertical one and the colour intensity is given by how many of those 100 solutions pass through the point (t, y)

It’s not clear to me what you want to achieve, from what kind of input. Usually a heatmap is not a series of curves. Please clarify, and provide an MWE generating the data.

Are you saying you want a plot with time on the horizontal axis, the curve index on the vertical axis, and the curve’s height represented by color?

If so, just concatenate the vectors representing the curves to make a 2D array, and then `heatmap` that array. A surface plot might also be a reasonable choice, given the shapes of those curves.

You can just plot all your curves using a transparent color, otherwise you have to do your histogram, it should be faster in Julia.

It’s more like time is in the horizontal axis, f(t) is the vertical axis and the height is given by how many curves pass through a point (t, f(t)). I’ll try to generate a MWE if it’s not that clear but I might not be able to do it

With GMT.jl you would prepare a Mx3 array with `t, f(t), curve_value_at(t, f(t))` and compute a grid with counting at each cell, Something like

``````G = blocmean(data_matrix, region=(0,t_max,0,ft_max), inc=cell_width, npts=:n);
imshow(G, fmt=:png)
``````

Given that you have a lot of points, a `contourf` sounds more adapted ?
Assuming you have `p(x,t)` for each `x` and `t` create a matrix out of it and give `x` and `t` for horizontal and vertical axis.
Something like

``````using Distributions, Plots
x = range(-5, 5, length = 100);
s = range(0.01, 3.0, length =  100);
Z = reduce(hcat, [pdf(Normal(0, exp(sig)), x) for sig in s])
contourf(x, s, Z', xlabel = "x", ylabel = "sig")
`````` Note that you can still replace `contourf` by `heatmap` to get more or less the same result 