Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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?

share|improve this question
    
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 –  rm -rf Mar 7 '13 at 16:02
    
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? –  JohnD Mar 7 '13 at 16:21
    
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] –  rm -rf Mar 7 '13 at 16:24
    
Gotcha. Just didn't know about that, but I will use it henceforth. –  JohnD Mar 7 '13 at 16:25
    
Better now than tomorrow! I did it for you this time :) –  rm -rf Mar 7 '13 at 16:35
show 1 more comment

1 Answer

up vote 8 down vote accepted

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

share|improve this answer
    
Thanks, this is exactly what I need. –  JohnD Mar 7 '13 at 16:24
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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