3
$\begingroup$

The following should produced a plot with an orange outlined disc labelled "A" on the dotted line. Epilog produces the dotted line and the text label but is unable to produce the disc.

data = {{{2006, 10, 1}, 10}, {{2006, 10, 15}, 12}, {{2006, 10, 30}, 15}, 
        {{2006, 11, 20}, 20}};

DateListPlot[data, 
 Epilog -> {
   {Gray, Dashing[Tiny], InfiniteLine[{{2006, 11, 2}, 0}, {0, 1}]},
   {White, EdgeForm[Orange], Disk[{{2006, 11, 2}, 10}]}, 
   {Orange,  Inset["A", {{2006, 11, 2}, 10}]}}
]

enter image description here

Instead of a white disc outlined in orange it is showing an orange line. I have specified the x-coordinate with a date as directed by DateListPlot's documentation. It also does not work for Circle; but I need Disk in any case.

Is this a bug or am I doing something incorrectly?

10.3 Win 7 Pro 64 bit.

$\endgroup$
4
$\begingroup$

Your behavior is caused by the fact that the actual scales on the two axes are wildly different. This honestly seems bad design or at least an unintended consequence.

Using your definitions, consider the following:

PlotRange@DateListPlot[data]

(* Out: {{3.36865*10^9, 3.37297*10^9}, {0., 20.}} *)

The horizontal axis ranges over the billion units, whereas the ordinate only over a few tens of units. When you specify your Disk without specifying the radius, the program draws a disk with unit radius. A 1-unit radius is well visible on the vertical axis, but it is extremely compressed on the horizontal axis and appears like a straight line, because of the extreme difference in ranges.

An approach is to indicate a Scaled radius; we need different scaled values in the two directions to counteract the effect of the default non-square aspect ratio setting (which defaults to 1/GoldenRatio) and still get a round circle:

DateListPlot[data,
 Epilog -> {
   {Gray, Dashing[Tiny], 
    InfiniteLine[{{2006, 11, 2}, 0}, {0, 1}]}, {White, 
    EdgeForm[Orange], Disk[{{2006, 11, 2}, 10}, Scaled[{0.05, 0.05 GoldenRatio}]]},
   {Orange, Inset["A", {{2006, 11, 2}, 10}]}
  }
]

scaled

I exaggerated the radius here to make it more easily visible; you will want to adjust the Scaled directive within Disk to suit your taste.

$\endgroup$
  • 1
    $\begingroup$ Seems like the big number is due to date converted to AbsoluteTime, i.e. seconds since January 1, 1900: DateString[3.36865*10^9] is Sun 1 Oct 2006 00:06:40, the first data point. $\endgroup$ – egwene sedai Feb 17 '16 at 15:20
  • 1
    $\begingroup$ Oh, the ellipse form of Disk. I was trying different values for the circle form. No wonder it didn't work. Nice bit with Scaled as and, indirectly, AspectRatio. I'll let this sit for a bit just in case. $\endgroup$ – Edmund Feb 17 '16 at 17:20

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.