3
$\begingroup$

I want to add arrowheads and labels to the following plot.

P1 = Plot[x, {x, 0, 2}, PlotStyle -> {Dashed, Red}, Filling -> Bottom];
P2 = Plot[6 x, {x, 0, 2}, PlotStyle -> {Dashed, Blue}];
 Show[P1, P2, AspectRatio -> Automatic, Frame -> True, 
 PlotRangePadding -> None, AxesOrigin -> {0, 0}, Axes -> None, 
 FrameStyle -> Directive[Black],  
 LabelStyle -> {18, Bold}, 
 FrameLabel -> {{None, "T"}, {"w", None} }, ImageSize -> 500]

I want the arrowheads towards the origin and the label (say, "w=T") to be on the curve.

$\endgroup$
4
$\begingroup$

Draw with graphics primitives using Epilog

P1 = Plot[x, {x, 0, 2}, PlotStyle -> {Dashed, Red}, Filling -> Bottom];
P2 = Plot[6 x, {x, 0, 2}, PlotStyle -> {Dashed, Blue}];
Show[P1, P2, AspectRatio -> Automatic, Frame -> True, 
 PlotRangePadding -> None, AxesOrigin -> {0, 0}, Axes -> None, 
 FrameStyle -> Directive[Black], LabelStyle -> {18, Bold}, 
 FrameLabel -> {{None, "T"}, {"w", None}}, ImageSize -> 500, 
 Epilog -> {
   Arrow[{{.2, .2}, {.1, .1}}],
   Arrow[{.05 {1, 6}, {1, 6} .02}], 
   Rotate[Text[Style["w=t", FontSize -> 20], {.95, 1.1}], Pi/4]}]

enter image description here

$\endgroup$
  • $\begingroup$ Thanks a lot! How can I put arrows labeling the axes (I mean "---- w ----->")? Actually the axes labeling looks a bit odd. Want to modify them.. $\endgroup$ – Physics Moron Mar 1 '16 at 21:14
  • $\begingroup$ Also how to get rid of that double (0,0) at the origin? $\endgroup$ – Physics Moron Mar 1 '16 at 21:21
  • 1
    $\begingroup$ putting graphics outside the plot axes is actually quite a pain. You can theoretically use graphcs as your FrameLabels, but getting them sized right is a chore. You can of course use the gui drawing tools.. Personally I take it to powerpoint at that stage. $\endgroup$ – george2079 Mar 1 '16 at 21:28
  • 1
    $\begingroup$ to get rid of the zero you need to use FrameTicks, manually specify the ticks you do want. $\endgroup$ – george2079 Mar 1 '16 at 21:32
3
$\begingroup$

As an alternative to Epilogyou can use the PlotStyle settings to add arrows:

Plot[{x, 6 x}, {x, 0, 2}, Filling -> {1 -> Bottom}, 
 PlotRange -> {0, 2}, AspectRatio -> 1, PlotRangePadding -> None, 
 AxesOrigin -> {0, 0}, Axes -> None, Frame -> True, 
 FrameStyle -> Directive[Black], LabelStyle -> {18, Bold}, 
 FrameLabel -> {{None, "T"}, {"w", None}}, ImageSize -> 400, 
 PlotStyle -> {({Arrowheads[{{-.05, 0.}, {.5, 1/2, 
                 Graphics[Text[Style["w = T\n", Large, Bold, Italic, Black]]]}}], 
                 Red, Dashed, Arrow @@ #} &), 
               ({Arrowheads[{{-.05, 0.}}], Blue, Dashed, Arrow @@ #} &)}]

Mathematica graphics

Alternatively, you can provide the Arrowheads specs as part of PlotStyle and post-process the Plot output to replace Lines with Arrows to get the same picture.

Plot[{x, 6 x}, {x, 0, 2}, Filling -> {1 -> Bottom}, 
  PlotRange -> {0, 2}, AspectRatio -> 1, PlotRangePadding -> None, 
  AxesOrigin -> {0, 0}, Axes -> None, Frame -> True, 
  FrameStyle -> Directive[Black], LabelStyle -> {18, Bold}, 
  FrameLabel -> {{None, "T"}, {"w", None}}, ImageSize -> 400, 
  PlotStyle -> {{Arrowheads[{{-.05, 0.}, {.5, 1/2, 
        Graphics[Text[Style["w = T\n", Large, Bold, Italic, Black]]]}}], Red, Dashed}, 
                {Arrowheads[{{-.05, 0.}}], Blue, Dashed}}] /. Line -> Arrow
$\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.