4
$\begingroup$

I am trying to create a ListPlot where the size of each marker is controlled individually.

The best solution I have found so far is to wrap every data point in Style with its own PointSize value, as suggested here

ListPlot[Table[Style[RandomReal[{-2, 2}, 2], PointSize[RandomReal[{0, 0.03}]]], {i, 100}]]

enter image description here

However, this type of scaling does not allow reducing the size to zero, but keeps the marker size constant at some point:

ListPlot[Table[Style[{i, 2}, PointSize[0.08 - 0.002*i]], {i, 50}]

enter image description here

How can I ensure that the scaling of the markers is really linear with respect to Pointsize all the way to zero?

$\endgroup$

1 Answer 1

6
$\begingroup$

This is certainly suboptimal behavior, if not a bug. You can workaround the issue by using PlotStyle->None and including Opacity[1] in your style:

ListPlot[
    Table[Style[RandomReal[{-2,2},2],Opacity[1],PointSize[RandomReal[{0,0.03}]]],{i,100}],
    PlotStyle->None
]

enter image description here

And, your second example:

ListPlot[
    Table[Style[{i,2},Opacity[1],PointSize[0.08-0.002*i]],{i,50}],
    PlotStyle->None
]

enter image description here

$\endgroup$
1
  • $\begingroup$ Thank you for providing the work around, that helped a lot :) $\endgroup$
    – Hausdorff
    Apr 14, 2021 at 10:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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