# Change Style of Points

I was wondering if it's possible to change the style of aPoint with another symbol e.g.: cross, x etc...

It may sound weird-it is a Point after all, but I would like to have crosses instead of points in the following code

  Manipulate[Module[{data, inside, insidepts}, SeedRandom[n];
data = RandomReal[{-1, 1}, {m, 2}];
insidepts = Cases[data, {x_, y_} /; x^2 + y^2 < 1];
inside = Length[insidepts];
Text@
Style[
Column[
{Graphics[{PointSize[0.0001], Red, Disk[{0, 0}, 1], Blue,
Point[data]}, ImageSize -> If[format, 500, 350]],
Row[{"inside: ", inside, "\toutside: ", m - inside, "\ttotal: ",
m}],
Row[{"π=4 x ", inside, "/", m, " = ", 4. inside/m}]}], "Label"]],
{{n, 1, "random seed"}, 1, 1000, 1, Appearance -> "Labeled"},
{{m, 1, "sample size"}, 1, 100000, 1, Appearance -> "Labeled"},
{{format, False, "large format"}, {True, False}},
AutorunSequencing -> {1, 2}]

-
 hi, if you want to use crosses instead of points, then why not use a cross in the first place? why use point then try to change it to cross afterwords? sorry if I am missing something more here. – Nasser Dec 11 '12 at 15:12

It's a bit faster to create one marker, and use GeometricTransform to position it where needed than to use individual placements with Text or Inset:

Manipulate[SeedRandom[n];
data = RandomReal[{-1, 1}, {m, 2}];
insidepts = Cases[data, {x_, y_} /; x^2 + y^2 < 1];
inside = Length[insidepts];
Text@Style[
Column[{Graphics[{PointSize[0.0001], Red, Disk[{0, 0}, 1], Blue,
GeometricTransformation[
Line[{{Offset[{-2, 2}, {0, 0}],
Offset[{2, -2}, {0, 0}]}, {Offset[{-2, -2}, {0, 0}],
Offset[{2, 2}, {0, 0}]}}], Dynamic[data]]},
ImageSize -> If[format, 500, 350]],
Row[{"inside: ", inside, "\toutside: ", m - inside, "\ttotal: ",
m}], Row[{"\[Pi]=4 x ", inside, "/", m, " = ", 4. inside/m}]}],
"Label"], {{n, 1, "random seed"}, 1, 1000, 1,
Appearance -> "Labeled"}, {{m, 1, "sample size"}, 1, 100000, 1,
Appearance -> "Labeled"}, {{format, False, "large format"}, {True,
False}}, AutorunSequencing -> {1, 2}]


I used Line with Offset coordinates to construct a cross, but you could use Inset["\[Cross]", {0,0}] instead.

-
 hi Brett; I tried your nice solution. It is faster for small 'sample size' than using ListPlot or Text, but I noticed as sample size got large (say over 20,000 and more, it became slow again) and it seems to fill the whole screen more densely than using Point so the disk below it will not be visible at around sample size 50,000 at all. Not sure why myself, since I really do not understand the trick you used (too advanced for me at this moment to understand it fully) – Nasser Dec 11 '12 at 15:49 This is a nice solution! – Szabolcs Dec 11 '12 at 15:58 @NasserM.Abbasi You can make the lines thinner to keep the disk visible, but then it tends to get blurry because of antialiasing (and turning off antialiasing will fill up the region again.) At the heart of it is that you're necessarily drawing more blue ink with a cross (or any other shape.) – Brett Champion Dec 11 '12 at 15:58 Thank you very much! This is really a nice solution! It's not that slow;I think I can hardly tell the difference between that and Point.Thank's! – Thanos Dec 11 '12 at 16:52

Given your example "point" symbols (cross, plus) and the need for speed if you want live updating in Manipulate, I recommend that you format your symbols as a series of lines, and display all of these lines in a single Line expression.

The size of the X's is controlled by the parameter of makeXfun.

You can use Opacity to reduce the inevitable visual density of the "points" in your graphic.

makeXfun[r_] :=
Compile[{{xy, _Real, 1}},
{{xy + {-r, -r}, xy + {r, r}}, {xy + {-r, r}, xy + {r, -r}}}]

Manipulate[
Graphics[{
{Red, Disk[{0, 0}, 1]},
{Blue, Opacity[0.5],
Line[Join @@ makeXfun[0.015] /@ RandomReal[{-1, 1}, {Round[samp^2], 2}]]},
{Black, Text["Sample size: " <> ToString@Round[samp^2], {0, -1.2}]}
}, ImageSize -> 400],
{samp, 1, 300, 1}
]


For plus symbols instead of X's you would use something like:

makePlusfun[r_] :=
Compile[{{xy, _Real, 1}},
{{xy + {-r, 0}, xy + {r, 0}}, {xy + {0, r}, xy + {0, -r}}}]

-
 Oh my God! This a very sophisticated solution, I could have never thought of!!!Thank's! – Thanos Dec 11 '12 at 16:53 @Thanos I'm curious, how does the performance of this method compare to that of Brett's solution? I can't run his on version 7 to compare. – Mr.Wizard♦ Dec 11 '12 at 17:10 Brett's solution is a bit faster/lighter. Yours start to become slow from ~7000 while his the critical point is ~10000. – Thanos Dec 11 '12 at 17:37

You can use Text, but it gets much slower than using Point.

Manipulate[Module[{data, inside, insidepts}, SeedRandom[n];
data = RandomReal[{-1, 1}, {m, 2}];
insidepts = Cases[data, {x_, y_} /; x^2 + y^2 < 1];
inside = Length[insidepts];
Text@Style[
Column[{Graphics[{Red, Disk[{0, 0}, 1], Blue,
Text[Style["\[Cross]", 12], #] & /@ data},
ImageSize -> If[format, 500, 350]],
Row[{"inside: ", inside, "\toutside: ", m - inside, "\ttotal: ", m}],
Row[{"\[Pi]=4 x ", inside, "/", m, " = ", 4. inside/m}]}], "Label"]],
{{n, 1, "random seed"}, 1, 1000, 1, Appearance -> "Labeled"},
{{m, 1, "sample size"}, 1, 100000, 1, Appearance -> "Labeled"},
{{format, False, "large format"}, {True, False}},
AutorunSequencing -> {1, 2}]


-
 Thank you very much for your answer! You are right that it's much slower than Point... But it is a decent solution! Thank's! – Thanos Dec 11 '12 at 16:45

There is no styling for Point as for plot markers. Hence you can use Show with ListPlot added to your Graphics. I use the standard "x" for the x. I think from Paletts there might be a better looking cross symbol to use if you search there.

Manipulate[
Module[{data, inside, insidepts},
SeedRandom[n];
data = RandomReal[{-1, 1}, {m, 2}];
insidepts = Cases[data, {x_, y_} /; x^2 + y^2 < 1];
inside = Length[insidepts];

Text@Style[Column[{
Show[
Graphics[
{
PointSize[0.0001],
Red, Disk[{0, 0}, 1]
},
ImageSize -> If[format, 500, 350]
],

ListPlot[data, PlotMarkers -> Style["x", 9]]
],

Row[{"inside: ", inside, "\toutside: ", m - inside, "\ttotal: ",m}],
Row[{"\[Pi]=4 x ", inside, "/", m, " = ", 4. inside/m}]}], "Label"]
],

{{n, 1, "random seed"}, 1, 1000, 1,Appearance -> "Labeled"},
{{m, 1, "sample size"}, 1, 100000, 1, Appearance -> "Labeled"},
{{format, False, "large format"}, {True,False}},

SynchronousUpdating -> False,
SynchronousInitialization -> False,
ContinuousAction -> False,

AutorunSequencing -> {1, 2}
]


But with so many points you have, I do not see what is the point of this really, as it will not make any difference after few points, it is hard to see what is there any way. (I also noticed it is a little slower that Point

-
 Thank you very much for your answer! I would like to use crosses in order to compare it with a similar output from matlab-class rules! You are right that it's slower than Point... Perhaps I should change it in Matlab where it's easier. No matter what, thank you very much for your answer! – Thanos Dec 11 '12 at 16:48