0
$\begingroup$

I want to plot this function,

cη0111ax[V_, X_] := 1/2 E^(-(1/2) Re[V X^2]) V^3 Abs[X/V]^2;

Plot[cη0111ax[4, X], {X, 0, t}
  , PlotRange->{{0, 2}, {0, 1}}, Frame->True
  , PlotLegends->{TextString@Row@{"X=", 1, "\n", "η=", cη0111ax[4, 1]*100, "%"}} 
  , Filling -> Axis
]

I use TextString Row@{"X=", t, "\n", "η=", cη0111ax[4, t]*100, "%"} to add a text that denotes the value x and cη0111ax[4, t] at point t. However, I can't put it inside of the figure. Adding a frame for text is also preferable. What can I do, thanks!

Moreover, hot to control the text format.

$\endgroup$
1
$\begingroup$

As my reputation is too low to comment, I'd like to respond with an answer:

You can use Placed and Scaled together with PlotLegends as following:

Plot[c\[Eta]0111ax[4, X], {X, 0, t},PlotRange->{{0, 2}, {0, 1}},Frame->True, PlotLegends->Placed[{TextString@Row@{"X=", 1, "\n", "\[Eta]=", c\[Eta]0111ax[4, 1]*100, "%"}}, Scaled[{0.8,0.9}]],Filling -> Axis]

The coordinates passed over to Scaled define the (relative) position of your legend.

$\endgroup$
  • $\begingroup$ Great,Thank you! $\endgroup$ – YOUNGHI Mar 15 '17 at 11:08
0
$\begingroup$

Possible way

f[v_,x_]:=1/2 E^(-(1/2) Re[v x^2]) v^3 Abs[x/v]^2;
t=10;

Plot[f[4,x],{x,0,t},PlotRange->{{0,2},{0,1}}, 
PlotLegends->Placed[
LineLegend[{TextString@Row@{"X=",1,"\n","\[Eta]=",c\[Eta]0111ax[4,1]*100,"%"}},
LegendFunction->Frame,
LegendMarkerSize->{{55,10}}],{0.7,0.8}],
Frame->True,
Filling->Axis]

Mathematica graphics

$\endgroup$
  • $\begingroup$ Wonderful! Thank you! $\endgroup$ – YOUNGHI Mar 15 '17 at 11:11

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.