3
$\begingroup$

This should be very easy, but I can't make it to work properly. I need to add a circular disk in the following ListPlot code:

dot[gamma_] := Disk[{gamma, gamma 5}, 0.25]

graph1[gamma_] := ListPlot[
    Table[{x, gamma x^2},
        {x, -4, 4, 0.5}
    ],
Frame -> True,
Ticks -> All,
GridLines -> Automatic,
GridLinesStyle -> Directive[GrayLevel[0.5], Dashed],
PlotRange -> All,
PlotStyle -> Thick,
Joined -> True,
Mesh -> None,
InterpolationOrder -> 4,
Epilog -> {Red, dot[gamma]}  (* This disk should stay circular, not oval! *)
]

graph1[-1]

Currently, the red disk is a deformed oval. I need it to stay circular, whatever the AspectRatio of the plot. What's wrong with this code?

$\endgroup$
2
  • 4
    $\begingroup$ Add AspectRatio -> Automatic, or use Point instead of Disk. $\endgroup$
    – Domen
    Commented Aug 26, 2023 at 15:44
  • 2
    $\begingroup$ If the image aspect ratio does not equal the coordinate aspect ratio, then circles appears as ellipses. $\endgroup$
    – Michael E2
    Commented Aug 26, 2023 at 15:45

1 Answer 1

5
$\begingroup$

Change to use Offset:

dot[gamma_] := Disk[{gamma, gamma 5}, Offset[{4, 4}]]

enter image description here

$\endgroup$
6
  • $\begingroup$ What is the Offset in the Disk? $\endgroup$
    – Cham
    Commented Aug 26, 2023 at 15:47
  • $\begingroup$ Please change to {10,4} as an example to see the effect. Also press F1 for the doc page that has example(s). $\endgroup$
    – Syed
    Commented Aug 26, 2023 at 15:49
  • $\begingroup$ @Cham It's the radius. Look up Offset and Scaled, etc. It's a question of image coordinates vs. graphics coordinates....See docs for Plot > Options > Epilog > 2nd example. $\endgroup$
    – Michael E2
    Commented Aug 26, 2023 at 15:49
  • $\begingroup$ Is there a way to make the point size "absolute", i.e the same size on screen whatever the AspectRatio and whatever the PlotRange? $\endgroup$
    – Cham
    Commented Aug 26, 2023 at 16:04
  • $\begingroup$ Isn't it compliant with those two requirements already? $\endgroup$
    – Syed
    Commented Aug 26, 2023 at 16:06

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.