4
$\begingroup$

Plot with default aspect ratio.

With[{p = 2.5}, 
  Plot[Sin[x], {x, 0, 2 π}, 
    Epilog -> 
      {{{Red, 
         Disk[{p, Sin[p]}, 0.2, {ArcTan[Cos[p]] + π/2, ArcTan[Cos[p]] + 3*π/2}]}, 
        {Green, 
         Disk[{p, Sin[p]}, 0.2, {ArcTan[Cos[p]] + 3*π/2, ArcTan[Cos[p]] + 5*π/2}]}}}]]

plot1

Plot with 1:1 aspect ratio.

With[{p = 2.5}, 
  Plot[Sin[x], {x, 0, 2 π}, 
    Epilog -> 
      {{{Red, 
         Disk[{p, Sin[p]}, 0.2, {ArcTan[Cos[p]] + π/2, ArcTan[Cos[p]] + 3*π/2}]},   {Green, 
         Disk[{p, Sin[p]}, 0.2, {ArcTan[Cos[p]] + 3*π/2, ArcTan[Cos[p]] + 5*π/2}]}}}, 
    AspectRatio -> Automatic]]

plot2

The two inputs differ only in that AspectRatio -> Automatic has been added in the second case.

I want to have the sine curve look like the one in the 1st but have the red/green disk look the one in 2nd ploy. How can I do that?

Notice that the red/green edge of the disk is mathematically perpendicular to the tangent of the $\sin(x)$ in both plots, but because of the distortion introduced by the default aspect ratio, it looks disk does not look perpendicular in the 1st plot.

Is it possible to have the plot in the default aspect ratio, but the objects drawn by 'Epilog' in aspect ratio 1:1?

To day it another way, I want the disk to act like a 'Point'. A point drown by Epilog does not change its shape under different aspect ratios. I can't use Point because I can not specify two different colors for each half of a point.

$\endgroup$
  • 2
    $\begingroup$ Try using Offset radii for the disks, e.g. Disk[{1,2}, Offset[10]] $\endgroup$ – Carl Woll Dec 26 '19 at 0:25
3
$\begingroup$

I don't see any way to do it by playing with aspect ratio, You can get the plot to look the way you want to by using AspectRatio -> Automatic and applying scaling functions in the vertical direction. Like so:

With[{p = 2.5, k = GoldenRatio},
  Plot[Sin[x], {x, 0, 2 π}, 
    Epilog -> 
      {{{Red, 
         Disk[{p, k Sin[p]}, 0.2, 
                {ArcTan[k Cos[p]] + π/2, ArcTan[ k Cos[p]] + 3*π/2}]}, 
        {Green, 
         Disk[{p, k Sin[p]}, 0.2, 
                {ArcTan[k Cos[p]] + 3*π/2, ArcTan[k Cos[p]] + 5*π/2}]}}}, 
    AspectRatio -> Automatic,
    ScalingFunctions -> {k # &, #/k &}]]

plot

| improve this answer | |
$\endgroup$

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.