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$
  • 1
    $\begingroup$ do you get what you want if you add the option PlotRangeClipping -> False? $\endgroup$ – kglr Feb 28 '18 at 13:17
  • $\begingroup$ @kglr No, it did not give the desired result $\endgroup$ – HD2006 Feb 28 '18 at 13:19
  • $\begingroup$ perhaps PlotRangePadding is helpful $\endgroup$ – user42582 Feb 28 '18 at 13:22
  • $\begingroup$ Somewhat related: (140710) $\endgroup$ – corey979 Feb 28 '18 at 14:55
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, privacy policy and cookie policy

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