3
$\begingroup$

Here's my code:

k = 1; 
L = 1; 
λ[n_] = (((2*n - 1)*Pi)/(2*L))^2; 
v[x_] = -50*x + 100; 
f[x_] = (300*x*Cos[11*x] + 100)*(1 - x); 
b[n_] = (2/L)*Integrate[(f[x] - v[x])*Sin[Sqrt[λ[n]]*x], {x, 0, L}]; 
w[x_, t_] = Sum[b[i]*Sin[Sqrt[λ[i]]*x]*Exp[(-λ[i])*k*t], {i, 1, 5}]; 
u[x_, t_] = v[x] + w[x, t];

Manipulate[Plot[{u[x, t], f[x], v[x]}, {x, 0, L}, 
     PlotStyle -> {{Thick, Black}, {Thick, Blue}, {Thick, Red}}, 
     AxesLabel -> {x, u}, PlotRange -> {-30, 120}, 
     PlotLegends -> "Expressions"], {t, 0, .5}]

Note how the right edge of the box of the output jumps back and forth depending on how many decimal places is shown for a specific $t$ value. How can I anchor that right edge so it doesn't move back and forth?

$\endgroup$
6
  • $\begingroup$ Please don't use styled formatting and subscript boxes if those are not necessary to the problem at hand (as in this case). It makes it extremely hard to read the question. Use InputForm instead $\endgroup$
    – rm -rf
    Commented Mar 7, 2013 at 16:02
  • $\begingroup$ Sorry, I don't know what you mean: I just copied and pasted my code. How do I do what you are suggesting without retyping those parts of my code? $\endgroup$
    – JohnD
    Commented Mar 7, 2013 at 16:21
  • $\begingroup$ I meant that stuff like \*SubsuperscriptBox[... is very hard to read if I don't have mma with me to copy-paste into the FE. You could do InputForm[Hold[stuff goes here]] and copy-paste everything inside the Hold[output here] $\endgroup$
    – rm -rf
    Commented Mar 7, 2013 at 16:24
  • $\begingroup$ Gotcha. Just didn't know about that, but I will use it henceforth. $\endgroup$
    – JohnD
    Commented Mar 7, 2013 at 16:25
  • $\begingroup$ Better now than tomorrow! I did it for you this time :) $\endgroup$
    – rm -rf
    Commented Mar 7, 2013 at 16:35

1 Answer 1

8
$\begingroup$

The answer is to replace "Expressions" with the more controllable LineLegend["Expressions"] as you can pass in options, such as LegendFunction:

PlotLegends -> LineLegend["Expressions",
  LegendFunction -> (Pane[#, ImageSize -> {100, 100}] &)]

enter image description here

and for a higher value of t

enter image description here

$\endgroup$
1
  • $\begingroup$ Thanks, this is exactly what I need. $\endgroup$
    – JohnD
    Commented Mar 7, 2013 at 16:24

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.