2
$\begingroup$

Is there any way to measure a distance from a graph in centimeter or inch exactly in Mathematica? I tried to use toolbar Ruler but I can only use it to measure width horizontally and can't switch it vertically to measure height. Also, I don't think we can use it to measure exactly the anything.

To be more specific, I am trying to measure the coordinates returns by function Offset[{10, 20}, {0, 0}] as bellow and check whether the offset distance is {10/72,20/72) inch or not.

Graphics[Rectangle[Offset[{10, 20}, {0, 0}], Offset[{-10, -20}, {1, 1}]], Frame -> True]

So how can I measure these distances? The purpose of the measurement is to check if I understand the offset coordinate correctly.

$\endgroup$
1
$\begingroup$

Here is one way:

g = Graphics[
  Annotation[
   Rectangle[Offset[{10, 20}, {0, 0}], Offset[{-10, -20}, {1, 1}]], 
   "Rectangle", "Region"], ImageSize -> 100, PlotRangePadding -> None];

Rasterize[g, "Regions"]
{{"Rectangle", "Region"} -> {{10., 20.}, {89., 79.}}}

Recommended reading:

$\endgroup$
  • $\begingroup$ What is the unit of "Region"? How to display it in inch or cm? $\endgroup$ – anhnha Oct 8 '17 at 6:13
  • $\begingroup$ @anhna It is pixels on the final rendered image. See the linked question about how they are connected to printer's points and inches. $\endgroup$ – Alexey Popkov Oct 8 '17 at 13:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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