I have a set of points in the plane which I would like to have "glow". I would like for each point to glow individually and I would also like some increase in the intensity corresponding to an increase in density of the points.
I've come up with a couple ideas for how to do this using DensityPlot
but neither are quite what I'm hoping for. I'll describe them below.
I need some points, say
pts = Table[{Re[E^(I t/2 - t/10)], Im[E^(I t/2 - t/10)]}, {t, 1, 50}];
The first idea is to consider an density function like
$$ \frac{1}{\epsilon + \min_{a \in \text{pts}}\operatorname{dist}((x,y),a)}. $$
My code for this is
eps = 1/16; exponent = 1/2;
distfunc1[x_, y_] =
1/(eps + Min[
Table[
((x - pts[[k, 1]])^2 + (y - pts[[k, 2]])^2)^(exponent),
{k, 1, Length[pts]}
]
]);
Show[
DensityPlot[distfunc1[x, y], {x, -1, 1}, {y, -1, 1},
PlotPoints -> 40],
Graphics[{PointSize[0.007], Point[pts]}]
]
which produces
The non-differentiability of the density function leads to sharp divisions between the glows. To get around that I considered adding the distances instead of taking the minimum, like
$$ \sum_{a \in \text{pts}} \frac{1}{\epsilon + \operatorname{dist}((x,y),a)}. $$
My definition is
distfunc2[x_, y_] =
Sum[
1/(((x - pts[[k, 1]])^2 + (y - pts[[k, 2]])^2)^(exponent) + eps),
{k, 1, Length[pts]}
];
By varying the parameters eps
and exponent
I can get parts of what I want. For example with eps = 1/4
and exponent = 1/2
I get nice smooth glows around the outer points but the inner region becomes too "hot":
With eps = 1/2
and exponent = 1/1400
the middle is no longer too hot and has the brightest glow from the density but the outer points no longer have significant idividual glows:
I haven't yet found a way to have a nice strong glow in the center as well as distinct, nontrivial glows for each of the outer points. I appreciate any ideas you may have.
Also, I'm new to Mathematica and I don't really know how ColorFunction
works. Is it easy to increase the range of lights/darks (i.e. increase contrast) in the color function used by DensityPlot
to render its pictures? I would like the darkest color to be near-black in the above pictures if possible.