2
$\begingroup$

I am plotting a dataset on ListPointPlot3D, and in order to give an idea of density of points I used opacity of 0.5. The problem is that that while the opacity of points behind one another is added, when multiple points overlap the opacity is not added; I need a way for the opacity of overlapping points to be added. A minimal example:

ListPointPlot3D[{{1, 1, 1}, {1, 1, 1}, {1, 2, 1}, {1, 2, 2}}, PlotStyle -> Directive[PointSize[0.1], Opacity[0.5]], ViewPoint -> {0, 0, Infinity}] 

Mathematica graphics

The first two points overlap completely (thus their opacity does not add), the latter two points overlap in x and y but differ in z (thus their opacity adds). I want to get the opacity of the first two points to add as well.

$\endgroup$
5
  • 2
    $\begingroup$ Could you post a minimal example of code that shows the problem? $\endgroup$
    – Jason B.
    Nov 13, 2013 at 19:28
  • $\begingroup$ @Jason B - here is a minimal example: ListPointPlot3D[{{1, 1, 1}, {1, 1, 1}, {1, 2, 1}, {1, 2, 2}}, PlotStyle -> Directive[PointSize[0.1], Opacity[0.5]], ViewPoint -> {0, 0, Infinity}] The first two points overlap completely (thus their opacity does not add), the latter two points overlap in x and y but differ in z (thus their opacity adds). I want to get the opacity of the first two points to add as well. $\endgroup$
    – Ixxie
    Nov 13, 2013 at 19:59
  • $\begingroup$ @YvesKlett - done. $\endgroup$
    – Ixxie
    Nov 13, 2013 at 20:51
  • 1
    $\begingroup$ How about offsetting duplicate points slightly? $\endgroup$
    – Yves Klett
    Nov 13, 2013 at 21:21
  • $\begingroup$ Perhaps useful mathematica.stackexchange.com/a/9191/193 $\endgroup$ Nov 14, 2013 at 2:04

2 Answers 2

2
$\begingroup$

It seems to work if the points are different by a very small amount. This doesn't fix the problem, but it may be a workable solution for you:

ListPointPlot3D[{{1, 1, 1}, {1, 1, 1}, {1, 2, 1}, {1, 2, 2}} + 
  RandomReal[{-.001, .001}, {4, 3}], 
 PlotStyle -> Directive[PointSize[0.1], Opacity[0.5]], 
 ViewPoint -> {0, 0, Infinity}, 
 PlotRange -> {{-0.01, 2.01}, {0.99, 2.01}, {-0.01, 2.01}}]

enter image description here

edit: Just saw that @YvesKlett had the same idea.

$\endgroup$
2
$\begingroup$

This solution specifies explicitly the opacity we expect each point to have, making absolutely sure it's right (I'm currently using 0.25 for opacity, as you can see in the second line of code).

(* Create a list in which each point is in its own set *)
list = List /@ {{1, 1, 1}, {1, 1, 1}, {1, 2, 1}, {1, 2, 2}};

(* Compute relative opacities based on multiplicity *)
opacities = list /. (Tally[list] /. {r_, m_} :> Rule[r, Opacity[0.25 m]]);

(* Add other directives *)
directive = Thread[{Sequence[PointSize[0.1], Blue], opacities}];

(* Plot! *)
ListPointPlot3D[list, PlotStyle -> directive]

opacity

$\endgroup$

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.