Skip to main content
Tweeted twitter.com/StackMma/status/790568691075256320
added 396 characters in body
Source Link
matheorem
  • 17.4k
  • 8
  • 49
  • 118

I am using Mathematica 11

Compare below two timings

Table[AbsoluteTiming[ListPlot[RandomReal[1., {n, 2}]]][[1]], {n, 1, 
  200, 20}]
(*{0.0922182, 0.0868473, 0.0458226, 0.0350156, 0.0440754, 0.0346732, \
0.0368516, 0.0397308, 0.0528617, 0.0459663}*)

and

Table[AbsoluteTiming[
   ListPlot[Thread[RandomReal[1., {n, 2}] -> Range[n]]]][[1]], {n, 1, 
  200, 20}]
(*{0.445452, 0.621644, 1.20737, 2.16653, 3.06852, 7.26112, 12.347, \
17.6615, 23.6164, 29.5285}*)

Why plotting labeled points is so slow? Is there workaround?


update

Thanks to rcollyer. The slowness is due to auto position algorithm gone crazy when number of points get larger.

A workaround is to specify label position explicitly, for example

Table[AbsoluteTiming[
   ListPlot[
    Labeled[#[[1]], #[[2]], Below] & /@ 
     Thread[RandomReal[1., {n, 2}] -> Range[n]]]][[1]], {n, 1, 200, 
  20}]
(*{0.201465, 0.359929, 0.470717, 0.415873, 0.556001, 0.644012, \
0.707094, 0.945657, 0.874655, 1.12489}*)

I am using Mathematica 11

Compare below two timings

Table[AbsoluteTiming[ListPlot[RandomReal[1., {n, 2}]]][[1]], {n, 1, 
  200, 20}]
(*{0.0922182, 0.0868473, 0.0458226, 0.0350156, 0.0440754, 0.0346732, \
0.0368516, 0.0397308, 0.0528617, 0.0459663}*)

and

Table[AbsoluteTiming[
   ListPlot[Thread[RandomReal[1., {n, 2}] -> Range[n]]]][[1]], {n, 1, 
  200, 20}]
(*{0.445452, 0.621644, 1.20737, 2.16653, 3.06852, 7.26112, 12.347, \
17.6615, 23.6164, 29.5285}*)

Why plotting labeled points is so slow? Is there workaround?

I am using Mathematica 11

Compare below two timings

Table[AbsoluteTiming[ListPlot[RandomReal[1., {n, 2}]]][[1]], {n, 1, 
  200, 20}]
(*{0.0922182, 0.0868473, 0.0458226, 0.0350156, 0.0440754, 0.0346732, \
0.0368516, 0.0397308, 0.0528617, 0.0459663}*)

and

Table[AbsoluteTiming[
   ListPlot[Thread[RandomReal[1., {n, 2}] -> Range[n]]]][[1]], {n, 1, 
  200, 20}]
(*{0.445452, 0.621644, 1.20737, 2.16653, 3.06852, 7.26112, 12.347, \
17.6615, 23.6164, 29.5285}*)

Why plotting labeled points is so slow? Is there workaround?


update

Thanks to rcollyer. The slowness is due to auto position algorithm gone crazy when number of points get larger.

A workaround is to specify label position explicitly, for example

Table[AbsoluteTiming[
   ListPlot[
    Labeled[#[[1]], #[[2]], Below] & /@ 
     Thread[RandomReal[1., {n, 2}] -> Range[n]]]][[1]], {n, 1, 200, 
  20}]
(*{0.201465, 0.359929, 0.470717, 0.415873, 0.556001, 0.644012, \
0.707094, 0.945657, 0.874655, 1.12489}*)
Source Link
matheorem
  • 17.4k
  • 8
  • 49
  • 118

ListPlot labeled points is extremely slow

I am using Mathematica 11

Compare below two timings

Table[AbsoluteTiming[ListPlot[RandomReal[1., {n, 2}]]][[1]], {n, 1, 
  200, 20}]
(*{0.0922182, 0.0868473, 0.0458226, 0.0350156, 0.0440754, 0.0346732, \
0.0368516, 0.0397308, 0.0528617, 0.0459663}*)

and

Table[AbsoluteTiming[
   ListPlot[Thread[RandomReal[1., {n, 2}] -> Range[n]]]][[1]], {n, 1, 
  200, 20}]
(*{0.445452, 0.621644, 1.20737, 2.16653, 3.06852, 7.26112, 12.347, \
17.6615, 23.6164, 29.5285}*)

Why plotting labeled points is so slow? Is there workaround?