1
$\begingroup$

I want to have a plot of $x^{\alpha}$, where $\alpha$ is an input, and a plot legend which displays something like $\alpha = \# \text{ rad}$ on the following plot, where # is determined by the input. I tried to do this in the following way:

Plot1[\[Alpha]_] := 
 Plot[{x^\[Alpha]}, {x, 2, 3}, PlotRange -> All, ImageSize -> Large, 
  FrameLabel -> {"x" , "y"}, Frame -> True, 
  FrameStyle -> Directive[Black, 25], 
  PlotStyle -> {{Thick, Blue}}, 
  PlotLegends -> 
   Placed[{Style["\[Alpha] = " \[Alpha] " rad", 20]}, {0.7, 0.3}], 
  GridLines -> Automatic]

However, instead of the desired result for, say, $\alpha = 2$ (Plot1[2]) the legend reads "2 $\alpha$ = rad". How to force it to display correctly?

$\endgroup$

1 Answer 1

3
$\begingroup$

Use a Row to build the display equation, rather than having

Style["\[Alpha] = " \[Alpha] " rad", 20]

use

Style[Row[{"\[Alpha] = ", \[Alpha] , " rad"}], 20]

In the first example you have a Style[Times[...]], where you are multiplying the value and the string.

$\endgroup$

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.