7
$\begingroup$

I often face the problem that none of the usual symbolic constants Tiny, Small, Medium, or Large or similar works quite well. For instance I would like something between Medium and Large, or just a tiny bit more than Large. I then need to resort to absolute sizes which costs time and is somewhat frustrating as the only way I know is trial and error and my first shot is usually terribly off (not to mention it might be daunting when the graphics is complicated). What's also bad, when the range of the plot later changes (beyond my control), the absolute sizes need to be readjusted.

Is it possible to perhaps find what values Medium and Large evaluate to, say for PointSize, and use some arithmetic on those?

EDIT: The suggested duplicate question deals with the size of the Graphics as a whole. I would primarily be interested in the meaning of these tokens for scaling of graphic primitives, like the values of PointSize (as originally mentioned but probably only too subtly), font size within a Style, Thickness, Arrowheads, and similar. Any subset of the mentioned, should the generic form make the question too broad. The method proposed in the linked question can not be adapted to this case in any straightforward way.

$\endgroup$
2

1 Answer 1

2
$\begingroup$

Here is a way to use Rasterize to approximate the size of things. I show it for points (as asked for in the OP) and lines. Points are not easy to get right. And Rasterize jumps from one rasterized size to the next as s increases in PointSize[s] (as well as Thickness[s]), so in the numbers below should be looked at as pretty close to correct. The floating-point estimates were rationalized, and the rationalizations checked. Both give the same sizes as {Tiny, Small, Medium, Large}.

(* rasterizer *)
rGraphics[size_, elem_][s_] := ColorConvert[
   Rasterize[
    Graphics[{White,
      size@s, elem},
     PlotRange -> 1/2],
    Background -> Black,
    RasterSize -> 2000],
   "Grayscale"];

Points:

(* Points *)
rPoint = rGraphics[PointSize, Point[{0, 0}]];

pointsizes = Table[
  rPoint[s] // ImageData // Sqrt[Total[#, 2]/Times @@ Dimensions[#]] &,
  {s, {Tiny, Small, Medium, Large}}]
(*  {0.003, 0.00490818, 0.0110642, 0.0172208}  *)

{1.`, 1.1319, 1.12977, 1.129125} pointsizes
(*  {0.003, 0.00555556, 0.0125, 0.0194444}  *)

test = Table[
  rPoint[s] // ImageData // Sqrt[Total[#, 2]/Times @@ Dimensions[#]] &,
  {s, {1.`, 1.1319, 1.12977, 1.129125} pointsizes}]
(*  {0.003, 0.00490818, 0.0110642, 0.0172208}  *)

(* rationalized *)
test = Table[
  rPoint[s] // ImageData // Sqrt[Total[#, 2]/Times @@ Dimensions[#]] &,
  {s, {3/1000, 1/180, 1/80, 7/360}}]
(*  {0.003, 0.00490818, 0.0110642, 0.0172208}  *)

pointsizes/test
(*  {1., 1., 1., 1.}  *)

Lines:

(* Lines *)
rLine = rGraphics[Thickness, Line[{{-1/2, 0}, {1/2, 0}}]];

thicknesses = Table[
  rLine[s] // ImageData // Total[#, 2]/Times @@ Dimensions[#] &,
  {s, {Tiny, Small, Medium, Large}}]
(*  {0.000556502, 0.00138791, 0.00278039, 0.00555686}  *)

test = Table[
  rLine[s] // ImageData // Total[#, 2]/Times @@ Dimensions[#] &,
  {s, thicknesses}]
(*  {0.000556502, 0.00138791, 0.00278039, 0.00555686}  *)

(* rationalized *)
test = Table[
  rLine[s] // ImageData // Total[#, 2]/Times @@ Dimensions[#] &,
  {s, {1/1800, 1/720, 1/360, 1/180}}]
(*  {0.000556502, 0.00138791, 0.00278039, 0.00555686}  *)

thicknesses/test
(*  {1.`, 1.`, 1.`, 1.`}   *)

Summary:

$\endgroup$

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.