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 have a set of 1million 2D points and I would like to produce an image 200x200 pixels where each point will have the size of a pixel (no more). Additionally each point may repeats several times so I would like to add some weight on it (small number of repetitions ->Light Green , ... , large number of repetitions ->Dark Green)

I am experimenting with the following data set before I use the real one :

data = Flatten[
   Table[Table[{i, j} k, {i, 1, 50}, {j, 1, 50}], {k, 1, 10, .5}], 2];

So which is the correct PointSize in my case and how can I set the intensity of each point ?

I am not that experienced on Graphics so I would appreciate any insight.

share|improve this question
    
PointeSize[0] is valid ? –  tchronis Mar 20 at 10:31
    
For the intensity, you could use different Opacity values for a given color or overlay several points with constant Opacity. –  Yves Klett Mar 20 at 10:46
    
Thank you @YvesKlett how can I overlay the points? –  tchronis Mar 20 at 10:50
1  
Try this line to get an idea: Graphics[{PointSize[Large], Point[#[[1 ;; 2]], VertexColors -> Directive[Opacity[#[[3]]], Blue]] & /@ RandomReal[{0, 1}, {3000, 4}]}] –  Yves Klett Mar 20 at 11:12
    
+1 thanks @YvesKlett –  tchronis Mar 20 at 11:22

2 Answers 2

up vote 3 down vote accepted
data = Flatten[
   Table[Table[{i, j} k, {i, 1, 50, .3}, {j, 1, 50, .3}], {k, 1, 
     10, .3}], 2];
Dimensions@data (*{833776, 2}*)

You can also do something like: (here I've assumed that you know what is the range of the data - 500)

m = SparseArray[Rule[IntegerPart[#], #2
                    ] & @@@ Tally[(200. Round[data/500., 1/200.] + 1.)]];

ArrayPlot[m, PlotRangePadding -> 0, ImageSize -> {200, 200}, Frame -> False,
             ColorFunction -> (Blend[{LightGreen, Darker@Green}, #] &)]

enter image description here

share|improve this answer
2  
With DensityHistogram there's no need to generate m: DensityHistogram[ data, PlotRangePadding -> 0, ImageSize -> {200, 200}, Frame -> False, ColorFunction -> (Blend[{LightGreen, Darker@Green}, #] &), PerformanceGoal :> "Speed" ] –  ArgentoSapiens Mar 20 at 21:47
    
@ArgentoSapiens Good point, you can post an answer. It calculates quite a long time though. –  Kuba Mar 20 at 21:56

To answer the question of how to set the point size to precisely one pixel: use AbsolutePointSize[1].

PointSize specifies the point diameter relative to the graphics width. Points whose size is controlled by this directive change size when the graphics is resized.

AbsolutePointSize will use printer's points for printable vector graphics (such as PDF) and pixels for on-screen display. AbsolutePointSize[1] will always display with a diameter of 1 pixel, regardless of the screen resolution. (This is not what the docs say, but this is what happens. The point-to-pixel ratio might be adjustable somewhere in the option inspector, not sure about this. By default it's 1, i.e. 72 "dpi".) When using AbsolutePointSize, the point size will be independent of the graphics size.

share|improve this answer
    
+1 Thanks @Szabolics I didn't suspect that. –  tchronis Mar 21 at 7:01

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.