1
$\begingroup$

I added margin to a plot and I am trying to use Epilog to write a comment inside the margin but it did not work? How can I writ inside the added margin without using the Drawing Tools

Plot[{x}, {x, 0, 3}, Frame -> True, PlotRange -> {0, 3}, 
  ImageMargins -> {{0, 0}, {0, 50}}, 
  Epilog -> {Text[Style["m=0", {FontSize -> 18, Black, 
    FontFamily -> "Times New Roman"}], Scaled[{.14, 1}]]}]

enter image description here

$\endgroup$
4
  • 1
    $\begingroup$ do you get what you want if you add the option PlotRangeClipping -> False? $\endgroup$
    – kglr
    Commented Feb 28, 2018 at 13:17
  • $\begingroup$ @kglr No, it did not give the desired result $\endgroup$
    – MMA13
    Commented Feb 28, 2018 at 13:19
  • $\begingroup$ perhaps PlotRangePadding is helpful $\endgroup$
    – user42582
    Commented Feb 28, 2018 at 13:22
  • $\begingroup$ Somewhat related: (140710) $\endgroup$
    – corey979
    Commented Feb 28, 2018 at 14:55

2 Answers 2

3
$\begingroup$

Use the options PlotRangeClipping and ImagePadding:

Plot[{x}, {x, 0, 3}, Frame -> True, PlotRange -> {0, 3}, 
 PlotRangeClipping -> False, ImagePadding -> {{Automatic, Automatic}, {Automatic, 50}}, 
 Epilog -> {Text[Style["m=0", {FontSize -> 18, Black, 
      FontFamily -> "Times New Roman"}], Scaled[{.14, 1.1}]]}]

enter image description here

$\endgroup$
4
$\begingroup$

Without PlotRangeClipping->False and using FrameLabel if you want to display the text as title:

Plot[{x}, {x, 0, 3}, Frame -> True, PlotRange -> {0, 3}, 
 ImagePadding -> {{Automatic, Automatic}, {Automatic, 30}}, 
 FrameLabel -> {{"y", ""}, 
   {"x", Text[Style["m=0", 20, Red, FontFamily -> "Times"]]}}, 
 BaseStyle -> {FontSize -> 18, Black, FontFamily -> "Arial"}]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.