3
$\begingroup$

The following is a link my original question:

I need List Plot points to have different color based on amount of neighbours?

The question was answered, and I used the first answer with ListPlot. It worked very well, taking maybe 10 seconds with 6k numbers in the list.

Now I have expanded the list of points to 120k and it wont work, not even when I let it run for a really long time. The rroblem is with the expression

List /@ list

I think that ListPlot can't handle a list containing 120k sublists, but maybe I'm wrong. I tried all the other answers given to my previous question, but they don't really work either even though I have 50 GB pf working memory.

Any ideas would be great.

Here's what a small sample of my list looks like.

{{14.24, 12.5}, {14.15, 12.67}, {14.22, 12.36}, {14.17, 12.71}, 
{13.61, 12.42}, {14.35, 12.49}, {14.12, 12.68}, {14.26, 12.59}, 
{14.07, 12.56}, {14.19, 12.57}, {14.06, 12.9}, {14.17, 12.59}, 
{14.19, 12.67}, {14.23, 12.5}, {14.07, 12.49}, {14.45, 12.45}, {13.7, 
12.8}, {14.12, 12.59}, {14.07, 12.7}, {14.23, 13.07}, {13.83, 12.13}, 
{14.35, 12.79}, {13.92, 12.41}, {14.08, 12.65}, {13.68, 12.16}, 
{13.84, 13.18}, {13.58, 11.61}, {12.58, 12.3}, {12.84, 13.25}, 
{13.57, 12.66}, {13.74, 12.18}, {13.24, 12.33}, {13.05, 12.47}, 
{13.26, 12.67}, {13.7, 12.35}, {13.68, 10.79}, {13.35, 12.19}, 
{13.77, 12.46}, {13.67, 12.15}, {12.75, 12.21}, {13.06, 12.81}}
$\endgroup$
3
$\begingroup$

This seems to work quite well for the visualization and returns results after a few seconds; in particular if we follow Carl Woll's suggestion and use the VertexColor option of the Point primitive.

n = 120000;
r = 0.1;
list = RandomVariate[MultinormalDistribution[{0, 0}, IdentityMatrix[2]], n];
nc = Length /@ Nearest[list -> Automatic, list, {Infinity, r}];

Graphics[
 Point[list, VertexColors -> ColorData["DarkRainbow"] /@ Rescale[N[nc]]]
 ]

enter image description here

Notice that the value of r is crucial for the runtime of Nearest (its runtime increases rapidly with r). But the runtime of Graphics should be independent of that.

$\endgroup$
  • 1
    $\begingroup$ It is much faster to use a multipoint object with VertexColors, e.g., Graphics[Point[list, VertexColors -> ColorData["DarkRainbow"] /@ Rescale[N[nc]]]] $\endgroup$ – Carl Woll Mar 28 at 21:46
  • 1
    $\begingroup$ Ha! Great! I did not know how to do that (I tried GraphicsComplex). $\endgroup$ – Henrik Schumacher Mar 28 at 21:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.