# Set PointSize to pixel size

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.

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

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}, #] &)] • 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" ] Mar 20, 2014 at 21:47
• @ArgentoSapiens Good point, you can post an answer. It calculates quite a long time though.
– Kuba
Mar 20, 2014 at 21:56

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

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 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.

• +1 Thanks @Szabolics I didn't suspect that. Mar 21, 2014 at 7:01