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}*)
ListPlot
without labels is relatively straightforward to do, but adding labels and attempting to have them not overlap each other, is not. In fact, it is probably NP Hard. So, what you're seeing is the effects of the positioning algorithm go crazy because it can't comply. $\endgroup$Labeled
supposed to be in the second example? Otherwise comparing the two doesn't show us thatLabeled
is slow... $\endgroup$coordinate->label
is dealt byListPlot
as labeled point. So I thought they are equivalent $\endgroup$