I have the following code:

ListLinePlot[pWoKC1, PlotRange -> {{0, 63}, {0, 1}},Epilog -> Line[{{0,datapCWMWoKCp[[1]]}, {63, datapCWMWoKCp[[1]]}}], PlotLabel -> "Title", AxesLabel -> {"X", "Y"}]

which produces the figure shown below. Top cap it off, I wish to add a label to the black line, but I am having difficulty working out how to change my code to do that.

enter image description here


I usually use Text inside of Epilog in order to add labels to various things:

 E^(-1/8 x) + 0.15, {x, 0, 63},
 AxesLabel -> {"X", "Y"},
 PlotLabel -> "Title",
 PlotRange -> {{0, 63}, {0, 1}},
 Epilog ->
   Line[{{0, 0.15}, {63, 0.15}}],
   Text[Style["Line Label", Black], {10, 0.18}]

Where I have Black inside of Style you can put various arguments like FontFamily and FontSize if you're interested in changing the style. If the default style is okay, then you don't really need the Style part and just Text["Line Label", {10, 0.18}] would do.

Plot using epilog to add a label to a line.


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.