Message Boards Message Boards

How can I add a plot label inside the plot?

Posted 16 days ago

I solve a nonlinear ODE system in Mathematica. But the labels of the plot are showed outside of the plot.
My notebook

  1. I want labels inside the plot
  2. Also labels are displayed like 30 ° not 30 Degree.
  3. How to zoom particular are in this plot like the following enter image description here
Attachments:
POSTED BY: J Prakash
5 Replies
  1. Use Placed:

    PlotLegends -> 
     Placed[{StringJoin["\[Alpha] = ", ToString[alpha]]}, 
      Scaled[{.5, .5}]]
    
  2. Write Quantity[30, "AngularDegrees"] instead of 30 Degree

  3. Use Inset.

POSTED BY: Gianluca Gorni

Some alternatives for 30°:

ToString[alpha,TraditionalForm]
PlotLegends->{Row[{"\[Alpha] = ",alpha}]}
POSTED BY: Michael Rogers

I dislike all the picky picayune details of plotting (not Mathematica's fault — seems a problem in whatever system). Especially Inset and PlotLegends.

Here's a code to give you some hints (plotsfNN generated with PlotLegends -> {Row[{"\[Alpha] = ", alpha}]}):

Show[
  Flatten[plotsfNN],
  Graphics[{Arrow[{{5.5,0.055},{5.6,0.36}}]}],
  Graphics[
  Inset[                   (* edits to plot: *)
   Show[First /@ plotsfNN, (*   remove legending *)
    AxesOrigin->{5,0},     (*   or use Frame instead of Axes *)
    PlotLabel->None,       (*   remove plot label *)
    PlotRange->{{5,6},{0,0.04}} (* select highlight *)
  ],
  Scaled[{5.5/7,0.75/1.7}], (* fiddle with placement *)
  {Center,Center},
  Scaled[0.4]]              (* fiddle with size *)
 ]]


enter image description here

POSTED BY: Michael Rogers
Posted 5 days ago

Thanks for your support. I have one more question. How can I get f, theta and phi values? The following commands didn't display the results for f(eta), theta(eta) and phi(eta).

solForAlphaNN[alpha_]:=NDSolve[{eq1,eq2,eq3,ics,bcs}/.alpha->alpha,{f,theta,phi},{eta,0,7},MaxStepSize->0.5,MaxSteps->10^3,Method->{"StiffnessSwitching",Method->{"ExplicitRungeKutta",Automatic}}];
POSTED BY: J Prakash

Try this change:

solForAlphaNN[alpha0_] := 
 NDSolve[{eq1, eq2, eq3, ics, bcs} /. alpha -> alpha0, {f, theta, 
   phi}, {eta, 0, 7}, MaxStepSize -> 0.5, MaxSteps -> 10^3, 
  Method -> {"StiffnessSwitching", 
    Method -> {"ExplicitRungeKutta", Automatic}}];

Also, N[b] = 0.1 is probably not what you meant. N is a system function, and N[b] = 0.1 sets an NValue for the symbol b. If you don't know what that means, then it is certainly not what you intended. I usually avoid starting my variable and function names with capital letters, and I especially avoid using single capitals, since several are used by the system. Like N. Sometimes when I want the variable to resemble traditional notation found in journals, I will compromise and use a double letter, like NN[b] = 0.1; similarly for, say, GG[r] = 5. But that's up to you. Just know that some things such as N[t] = 0.1 have a special meaning and may break your code.

POSTED BY: Michael Rogers
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract