To make a density map from a 2D set of data, the first step is to compute values for the third dimension. (Gnuplot has no facilities for computing these values automatically.) The simplest way is to make a 2D histogram; the plot is divided in small 2D regions, and the z-values are proportional to the number of points inside these regions. The following Python script will make an histogram from a time series of two dihedral angles.