5
$\begingroup$

How can I use a list of variables (possibly subscripted) as an AxesLabel without showing the braces.

For example,

Plot[{x, x^2}, {x, 0, 1}, AxesLabel -> {x, {Subscript[y, 1], Subscript[y, 2]}}]

Mathematica graphics

would look the same, just without the braces on the y-axis label.

$\endgroup$
6
$\begingroup$
Plot[{x, x^2}, {x, 0, 1}, 
 AxesLabel -> {x, Row[{Subscript[y, 1], " ", Subscript[y, 2]}]}]

enter image description here

$\endgroup$
  • $\begingroup$ That was easy, thanks! My example might have been too minimal, in that I want it to work automatically for arbitrary length lists. Using Riffle takes care of that: Plot[{x, x^2, x^3}, {x, 0, 1}, AxesLabel -> {x, Row[Riffle[{Subscript[y, 1], Subscript[y, 2],Subscript[y, 3]}, ", "]]}] $\endgroup$ – Chris K Sep 10 '17 at 23:20
5
$\begingroup$

I propose a slightly different form of Row:

Row[list,s] inserts s as a separator between successive elements.

And as Carl Woll commented:

The front end has special handling for "," as the second argument of Row, so that it automatically adds space after the comma as long as the comma isn't the last character of a line.

labels = {Subscript[y, 1], Subscript[y, 2]};

Plot[{x, x^2}, {x, 0, 1}, AxesLabel -> {x, Row[labels, ","]}]

enter image description here

$\endgroup$
  • $\begingroup$ Slicker than my Riffle! $\endgroup$ – Chris K Sep 11 '17 at 0:40
  • 5
    $\begingroup$ The front end has special handling for "," as the second argument of Row, so that it automatically adds space after the comma as long as the comma isn't the last character of a line. So, I would recommend Row[labels, ","] instead. $\endgroup$ – Carl Woll Nov 15 '17 at 6:17
  • 1
    $\begingroup$ @Carl Thanks for the usage tip! $\endgroup$ – Mr.Wizard Nov 15 '17 at 16:37
2
$\begingroup$

Another way:

Plot[{x, x^2}, {x, 0, 1}, 
 AxesLabel -> {x, HoldForm[Subscript[y, 1] Subscript[y, 2]]}]

or

Plot[{x, x^2}, {x, 0, 1}, 
     AxesLabel -> {x, 
       Graphics[{Text[
          HoldForm[Subscript[y, 1](*","*)Subscript[y, 2]], {0, 1}]}, 
        ImageSize -> 35]}]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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