I would like to generate a ListPlot
with the color for each point in the plot corresponding to a particular value (not associated with the position in the plot). I'd then like to add a legend indicating what the color means.
I'm currently solving the first part of the problem by essentially generating a separate ListPlot for each data point and then assigning a color to that ListPlot. Here's a toy example:
n = 5000;
pos = RandomVariate[NormalDistribution[0, 2], {n, 2}];
altitude = Norm /@ pos;
ListPlot[{#} & /@ pos,
PlotStyle -> ((Blend[{{Min[altitude], Yellow}, {Max[altitude],
Red}}, #] &) /@ altitude), AspectRatio -> 1]
So my questions are:
(1) Is this the only way to generate such a ListPlot
(it does the job but it seems inelegant and I suspect it's inefficient, though that's not a big concern for my application)?
(2) Is there an easy way to generate a legend which indicates the value of the color (i.e., a gradient bar which shows the color scale)?