Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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.

share|improve this question
2  
Could you post a minimal example of code that shows the problem? –  Jason B Nov 13 '13 at 19:28
    
@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. –  Ixxie Nov 13 '13 at 19:59
    
@YvesKlett - done. –  Ixxie Nov 13 '13 at 20:51
1  
How about offsetting duplicate points slightly? –  Yves Klett Nov 13 '13 at 21:21
    
Perhaps useful mathematica.stackexchange.com/a/9191/193 –  belisarius Nov 14 '13 at 2:04

2 Answers 2

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.

share|improve this answer

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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