1
$\begingroup$

I want disks of equal size to be depicted the same size on different outputs of Graphics and at the same time images should be nicely clipped without any unnecessary white area.

The first two images are nicely clipped but disks are not depicted the size.

The second two images depict the disks the same size but the second is not clipped nicely.

What I want can be seen in the fifth image (images sizes are of course different, but that does not matter for me).

o1 = Disk[#] & /@ {{0, 0}, {8, 2}};
o2 = Disk[#] & /@ {{0, 0}, {5, 0}};
Graphics[o1, Frame -> True]
Graphics[o2, Frame -> True]
b = RegionBounds[RegionUnion[Flatten@{o1, o2}]];
Graphics[o1, Frame -> True, PlotRange -> b]
Graphics[o2, PlotRange -> b, Frame -> True]
Clear[o1, o2, b]

enter image description here


enter image description here


enter image description here


enter image description here



enter image description here

$\endgroup$

1 Answer 1

4
$\begingroup$
o1 = Disk[#] & /@ {{0, 0}, {8, 2}};
o2 = Disk[#] & /@ {{0, 0}, {5, 0}};

You can use the still-undocumented form ImageSize -> a -> b (which makes $a$ user units correspond to $b$ printer's points):

Graphics[o1, Frame -> True, ImageSize -> 1 -> 30]

Graphics[o2, Frame -> True, ImageSize -> 1 -> 30]

enter image description here

$\endgroup$
2
  • $\begingroup$ Where have you found such usage of ImageSize? I can not see it in documentation. $\endgroup$ Commented Sep 17, 2023 at 13:35
  • 1
    $\begingroup$ It is not in documentation. Don't remember where I first came across this usage. It has appeared in Q/As on this site a number of times: e.g., 1, 2, 3, 4. Oldest post on this site using this form seems to be this answer by rm-rf. $\endgroup$
    – kglr
    Commented Sep 17, 2023 at 13:50

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.