5
$\begingroup$

I'm running Mathematica 9.0.1 under Mac OS X.

I'm not sure if this is a bug or whether I'm not supposed to apply a GeometricTransformation to a list containing graphic primitives and directives:

verts = {{0, 0}, {1, 0}, {Cos[60 Degree], Sin[60 Degree]}};
tri = {{PointSize[0.2], Point[verts]}, {Line[verts ~Append~ First@verts]}};

Translating purely in the vertical direction works how I expect it to:

Graphics[GeometricTransformation[tri, TranslationTransform[{0, #}] & /@ Range[0, 2]]]

vertical translation

Graphics[GeometricTransformation[tri, TranslationTransform[{#, 0}] & /@ Range[0, 2]]]

However, if the translation has a horizontal component, then the point size gets messed up, in the sense that it's not compensating for the size of the points with respect to the size of the graphic in the notebook:

horizontal translation

Is this a bug?

$\endgroup$

2 Answers 2

11
$\begingroup$

From the docs of PointSize[]:

The diameter (of the point) is given as a fraction of the total width of the plot.

In other words, it adjusts point sizes relative to the width. Since your plot widened after the transformation, it stands to reason that your points should grow in size as well.

To drive the point home, ponder upon the result of

{Graphics[{PointSize[0.2], Point[{0, 0}]}, PlotRange -> {{-1, 1}, {-2, 2}}], 
 Graphics[{PointSize[0.2], Point[{0, 0}]}, PlotRange -> {{-10, 10}, {-2, 2}}]}
// GraphicsColumn

(I deliberately did not upload the picture of the result, so as not to spoil the surprise. :P )

If you don't want this growth, consider using AbsolutePointSize[] instead.

$\endgroup$
1
  • $\begingroup$ It hadn't occurred to me to check the documentation for PointSize. I guess I was mistakenly expecting it to behave like the radius of a Disk[] object. $\endgroup$
    – Aky
    May 25, 2013 at 15:15
6
$\begingroup$

In my Mathematica work I frequently construct diagram in which I show polygons with their vertices represented by dots. I prefer to use Disk to draw the dots rather than Point because I feel doing so avoids the problems that can arise from having to specify the point size with either PointSize or AbsolutePointSize.

Your question illustrates the problem that can arise from using PointSize. Now let's look at the problem that can arise from using AbsolutePointSize.

verts = {{0, 0}, {1, 0}, {Cos[60 Degree], Sin[60 Degree]}};
tri = {{AbsolutePointSize[12],  Point[verts]}, {Line[verts~Append~First@verts]}};

The choice of 12pts looks good when the graphic is drawn at the default image size.

Graphics[GeometricTransformation[tri, TranslationTransform[{#, 0}] & /@ Range[0, 2]]]

Point.1.png

But look what happens when the image is down-sized by supplying an explicit ImageSize option. I think the vertices now look too big relative to the triangles because they do not change size.

Graphics[GeometricTransformation[tri, 
  TranslationTransform[{#, 0}] & /@ Range[0, 2]], ImageSize -> 150]

Point.2.png

Because problems can arise with both PointSize and AbsolutePointSize, I recommend representing vertices in graphics by Disk rather than Point. I further recommend using Polygon rather than Line for drawing polygons (the default filling of the polygon is easily removed).

vertices = {{0, 0}, {1, 0}, {Cos[60 Degree], Sin[60 Degree]}};
vertexPts = Disk[#, 0.06] & /@ vertices;
triangle = {Transparent, EdgeForm[Black], Polygon[vertices]};

Graphics[GeometricTransformation[{triangle, vertexPts}, 
  TranslationTransform[{#, 0}] & /@ Range[0, 2]]]

Disk.1.png

Now if I reduce the image size, the dots representing the shrink proportionally.

Graphics[GeometricTransformation[{triangle, vertexPts}, 
  TranslationTransform[{#, 0}] & /@ Range[0, 2]], ImageSize -> 150]

Disk.2.png

You might also consider one more simplification: using Translate in place of GeometricTransformation and TranslationTransform. Translate will give simpler code in your particular example and in many similar situations.

Graphics[Translate[{triangle, vertexPts}, {#, 0}] & /@ Range[0, 2]]

Disk.1.png

Graphics[Translate[{triangle, vertexPts}, {0, # Sin[60 Degree]}] & /@ Range[0, 2]]

Disk.3.png

$\endgroup$
2
  • 1
    $\begingroup$ One could use FaceForm[None] instead of Transparent so that only the polygons are affected. $\endgroup$ May 26, 2013 at 5:09
  • $\begingroup$ @J.M. +1 I have always wrapped my polygons in their own List along with Transparent, so it has never caused a problem for me. But I can see that, in general, using FaceForm[None] is cleaner. $\endgroup$
    – m_goldberg
    May 27, 2013 at 0:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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