1
$\begingroup$

I had the same question as How to add a vertical line to a plot and I have read the first answer using the Epilog function.

This answer solved my problem and my code is now working.

However, I don't understand why Epilog is needed by mathematica in the code. It is written in the documentation : "Epilog is an option for graphics functions that gives a list of graphics primitives to be rendered after the main part of the graphics is rendered.".

Indeed the code doesn't work without Epilog, it means if we directly put Line in the plot command. But why does Epilog solve this problem ? Why the fact to render the line after the rest of the graphic is rendered would make the thing work.

I don't understand this.

$\endgroup$
6
$\begingroup$

The normal environment for a Line instruction to live in would be the Graphics function environment.

Line is just one example of the many drawing instruction that Graphics knows.

The Plot function itself is not a Graphics environment and knows nothing about drawing functions. The result of a Plot statement, however, is a Graphics function with all drawing instructions included to create the desired plot.

The effect of the Epilog option is to pass the drawing instructions in its argument to this Graphics environment created by Plot. As the name suggests, this is done after the plot drawing instructions. There is a similar option called Prolog which also insert drawing instructions. However, this option inserts its argument before the plot drawing instruction.

$\endgroup$
  • 1
    $\begingroup$ Personally I have always been unconfortable with the term after and before in a context that has nothing to do with time, though that seems to be a established habit. Here the term after means that the graphics from the Epilog hides the other ones. (This is only a Note, Don't change your answer for this) $\endgroup$ – andre314 Aug 4 '18 at 16:32
  • $\begingroup$ @andre The use of before and after with regard to place, position, time, and motion goes back to Old English, and probably earlier. $\endgroup$ – Michael E2 Aug 4 '18 at 18:48
  • $\begingroup$ @andre You could really think of it as a process in time. The Graphics instructions are processed in order of appearance, which means that Prolog instructions execute before the Plot instructions. The Epilog instructions are executed after the Plot instructions have been evaluated. But before and after are quite common expressions of spatial localization as any dictionary may attest. $\endgroup$ – Sjoerd C. de Vries Aug 4 '18 at 19:01

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.