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'm running Mathematica 9.0.1 under Mac OSX.

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 the size of the points with respect to the size of the graphic in the notebook:

horizontal translation

Is this a bug?

share|improve this question

2 Answers 2

up vote 11 down vote accepted

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.

share|improve this answer
    
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. –  Aky May 25 '13 at 15:15

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

share|improve this answer
1  
One could use FaceForm[None] instead of Transparent so that only the polygons are affected. –  J. M. May 26 '13 at 5:09
    
@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. –  m_goldberg May 27 '13 at 0:29

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.