# Using Epilog and Graphics to plot points and lines

I'm attempting to put a point onto my Plot but need help with the point sizing and using the Graphics function. I'm not sure I'm going about this correctly, but I have been able to produce the lines that I'm looking for using the Line function inside the epilog option. I'm confused about how Mathematica handles marking up Plots. I also want to call out my intersection of the two lines and need help.

Here is what I'm looking for:

• Callout point of intersection with the (x,y) value at that point.
• Adjust the size of the point of intersection
• Add arrows to indicate the direction of the slope

I need clarification about how Mathematica combines its graphics rendering with its plots. I can use Line to place a line inside my Plot but then using Graphics to add other stuff causes errors. What is the proper way to understand how these are rendered so I can add markup to my Plots?

Here is the code with errors:

Plot[{2.13 + 0.7 (-7.4 + x), 2.13 + 0.9 (-8.9 + x)}, {x, 6, 20},
Epilog -> {
{Red, Line[{{14.15, 0}, {14.15, 6.855}}]},
{Red, Line[{{6, 6.855}, {14.15, 6.855}}]},
{Blue, Graphics[PointSize[0.1], Point[{14.15, 6.855}]]}},
PlotStyle -> Thick, PlotLabel -> "Supply & Demand",
AxesLabel -> {"Bushels", "Price"},
PlotLabels -> {"Demand", "Supply"}]


Here is the working Code:

Plot[{2.13 + 0.7 (-7.4 + x), 2.13 + 0.9 (-8.9 + x)},{x, 6, 20},
Epilog -> {
{Red, Line[{{14.15, 0}, {14.15, 6.855}}]},
{Red, Line[{{6, 6.855}, {14.15, 6.855}}]},
{Blue,Point[{14.15,6.855}]}},
PlotStyle -> Thick, PlotLabel -> "Supply & Demand",
AxesLabel -> {"Bushels", "Price"},
PlotLabels -> {"Demand", "Supply"}]

• I'm sorry there is an error in my slope calculation for demand. Please don't judge me! Commented Nov 13, 2022 at 23:31
• Have the labels been interchanged for "supply" and "demand"?
– Syed
Commented May 16, 2023 at 7:44

Try this:

Show[{
Plot[{2.13 + 0.7 (-7.4 + x), 2.13 + 0.9 (-8.9 + x)}, {x, 6, 20},
PlotStyle -> Thick, PlotLabel -> "Supply & Demand",
AxesLabel -> {"Bushels", "Price"},
PlotLabels -> {"Demand", "Supply"}],
Graphics[{Red, Line[{{14.15, 0}, {14.15, 6.855}}],
Line[{{6, 6.855}, {14.15, 6.855}}], Blue, PointSize[0.03],
Point[{14.15, 6.855}]}]
}]


You can also do it with the Epilog as follows:

Plot[{2.13 + 0.7 (-7.4 + x), 2.13 + 0.9 (-8.9 + x)}, {x, 6, 20},
Epilog -> {{Red, Line[{{14.15, 0}, {14.15, 6.855}}]}, {Red,
Line[{{6, 6.855}, {14.15, 6.855}}]},
{Blue, PointSize[0.05], Point[{14.15, 6.855}]}
}, PlotStyle -> Thick, PlotLabel -> "Supply & Demand",
AxesLabel -> {"Bushels", "Price"},
PlotLabels -> {"Demand", "Supply"}]


Have fun!

• Ah, so I'm placing my Graphics on top of my plot? In the first example you gave. Then how do I do the arrows? How do I place a coordinate point callout? Commented Nov 13, 2022 at 16:18
• You can combine everything wrapping the graphics functions by the Show. Have a look at Arrow. You use it like Line. For the coordinates of the point, try either Callout or Text. Have a look at all these functions in the documentation. They are easy to use. Commented Nov 13, 2022 at 16:56

To make the faulty version work and still use Epilog, replace Graphics[...] with First@Graphics[...]. This is to remove the Head Graphics and makes Epilog happy

Plot[{2.13 + 0.7 (-7.4 + x), 2.13 + 0.9 (-8.9 + x)}, {x, 6, 20},
Epilog -> {
{Red, Line[{{14.15, 0}, {14.15, 6.855}}]},
{Red, Line[{{6, 6.855}, {14.15, 6.855}}]},
{First@Graphics[{Blue, PointSize[0.03], Point[{14.15, 6.855}]}]}},
PlotStyle -> Thick, PlotLabel -> "Supply & Demand",
AxesLabel -> {"Bushels", "Price"},
PlotLabels -> {"Demand", "Supply"}]


• When this one is compiled it doesn't produce an error but it still doesn't create the point. Commented Nov 13, 2022 at 16:22
• @Ziggy There was no mention in the question about compile. I do not know anything about Compile and if it even supports plotting. May be post separate question on Compile not working with Plots? I was just answering your question on how to make Epilog accept Graphics. Commented Nov 13, 2022 at 16:24
• I'm talking about compiled as in when you hit shift + enter to have Mathematica run the code. This code you wrote compiles without errors inside the Mathematica notebook but still doesn't produce a blue dot. Commented Nov 13, 2022 at 16:29
• @Ziggy oh I thought you meant Compile command. The correct term to use is Evaluate and not Compile in Mathematica to mean what you meant as the two terms mean something different. As for the blue point, I was just using your code. You need to move the color inside the Graphics. I've updated the answer. Commented Nov 13, 2022 at 16:36
• Ahh, okay. Thank you! Commented Nov 13, 2022 at 16:37