0
$\begingroup$

This is a simple variation/spin off of this question, but I am having trouble. In the second example in the original question, I'm trying to get the $a=$ in the PlotLabel to be in TraditonalForm (with an italicized $a$ instead of a non-italic a).

testplot[a_] := Plot[a x^2, {x, 0, 3}, PlotLabel -> StringForm["a=`1`", a]]

testplot[2]

Edit: Here's my particular example of this issue in v10

   Table[ContourPlot[Norm[{x, y}, p] == 1, {x, -1.2, 1.2}, {y, -1.2, 1.2}, 
   PerformanceGoal -> "Accuracy", ImageSize -> 250, 
   PlotLabel -> Text["p=" <> ToString@p, FormatType -> TraditionalForm]], 
   {p, {1, 2, 3, 4, 10, 50, 500}}]
$\endgroup$
6
  • $\begingroup$ Even if you are taking code from an other question you should provide some code here. $\endgroup$
    – Öskå
    Commented Nov 26, 2014 at 15:20
  • $\begingroup$ I also suggest that you formulate here your question completely $\endgroup$ Commented Nov 26, 2014 at 15:38
  • $\begingroup$ PlotLabel -> Text["a=" <> ToString@a, FormatType -> TraditionalForm]? $\endgroup$
    – Öskå
    Commented Nov 26, 2014 at 15:41
  • $\begingroup$ @Öskå doesn't work $\endgroup$
    – JohnD
    Commented Nov 26, 2014 at 15:47
  • $\begingroup$ It works pretty fine for me. I don't know what else you are expecting then. $\endgroup$
    – Öskå
    Commented Nov 26, 2014 at 15:51

2 Answers 2

2
$\begingroup$

I believe this accomplishes your goal:

Table[ContourPlot[
   Norm[{x, y}, p] == 1, {x, -1.2, 1.2}, {y, -1.2, 1.2}, 
   PerformanceGoal -> "Accuracy", ImageSize -> 250, 
   PlotLabel -> Row[{TraditionalForm[HoldForm[p]], "\[ThinSpace]=", p}]], 
   {p, {1, 2, 3, 4, 10, 50, 500}}]

The \[ThinSpace] is included just to properly space before the equal sign.

$\endgroup$
0
$\begingroup$

I would avoid strings and just use an expression (Mathematica by default formats labels in TraditionalForm):

Table[
    ContourPlot[
        Norm[{x,y},p]==1,
        {x,-1.2,1.2},
        {y,-1.2,1.2},
        PlotLabel->HoldForm[p]==p
    ],
    {p,{1,500}}
]

enter image description here

In comparison to the accepted answer, note that the labels use a long equal sign instead of a regular equal sign, and the spacing on either side of the equal sign is even.

$\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.