2
$\begingroup$

I have a flat list of data {{x1,y1}, {x2,y2}, ..., {xn,yn}}, that I plot with a ListPlot. I now want each point to have it's own value of opacity, i.e., I generate a list {o1, o2, ..., on}.

The question is how can I put each oi value to be the Opacity[oi] of each point?

Here is an example of data like this.

ListPlot of data

UPD

I used the code described in the first response. Here's the result. Thank you for quick answer!

Solved

$\endgroup$
  • $\begingroup$ Consider accommodating ideas form this post $\endgroup$ – BlacKow Jun 1 '16 at 20:39
6
$\begingroup$
lst = Table[{Sin[n], Sin[2 n]}, {n, 50}];
opacities = RandomReal[1, {50}];

ListPlot[List /@ lst, PlotStyle -> (Opacity /@ opacities), BaseStyle -> PointSize[Large]]

Mathematica graphics

| improve this answer | |
$\endgroup$
  • $\begingroup$ Do you know if we can trick ListPlot to use ColorFunction without having Joined->True? $\endgroup$ – BlacKow Jun 1 '16 at 21:06
  • 1
    $\begingroup$ @BlacKow, maybe something like ListPlot[lst, PlotStyle -> (Opacity /@ opacities), ColorFunction -> "DarkRainbow", Joined -> True, BaseStyle -> PointSize[Large]] /. Line -> Point? $\endgroup$ – kglr Jun 2 '16 at 2:44
2
$\begingroup$

I wonder if you can use ColorFunction? Somehow ListPlot docs say that one of the plots has to be joined. You can use Graphics and plot points instead:

data = Transpose@{#, Sin[#]} &@Range[0, 2 Pi, 0.05];
op = Opacity /@ (Abs@Sin[#[[1]]]) & /@ data;

Show[Graphics[{Blue, Opacity[#1], Point[#2]} & @@@ 
   Transpose@{op, data}], Frame -> True]

enter image description here

| improve this answer | |
$\endgroup$

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.