Suppose I have the following coordinates that I want to plot:

xy = {{0.05, -0.000264728}, {0.15, -0.0125407}, {0.25, -0.0569049}, {0.35,-0.133636}, {0.45, -0.235416}, {0.55, -0.358514}, {0.65, -0.50575},{0.75, -0.68979}, {0.85, -0.948287}, {0.95, -1.46034}}

But suppose also, that I wish to vary the size of the dots in the plot using information contained in a corresponding list:

pointsize = {0.98, 0.94, 0.90, 0.83, 0.76, 0.66, 0.57, 0.41, 0.25, 0.09}

How can that be achieved? I suppose I need a base-size for points, and then weight this base by the content of the pointsize list, but exactly how that can be done in Mathematica I do not know.


You can use several approaches:


bcdata = Join[xy, List /@ pointsize, 2];

enter image description here

See the options BubbleScale and BubbleSizes for various ways to associate the third column with bubble sizes.


Alternatively, you can use Graphics using some normalization of pointsize as the radii of disks centered on points in xy:

Graphics[{Opacity[1], Lighter@Blue, 
  Disk @@@ Transpose[{xy, Normalize[pointsize, Max]/20}]}, Frame -> True]

enter image description here


ListPlot[List /@ xy, 
 PlotStyle -> Thread[Directive[Lighter@Blue, 
    PointSize /@ (Normalize[pointsize, Max]/10)]], PlotRange -> All, 
 Frame -> True, AspectRatio -> Automatic, PlotRangePadding -> Scaled[.05]]

enter image description here


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.