Message Boards Message Boards

0
|
234 Views
|
3 Replies
|
3 Total Likes
View groups...
Share
Share this post:

Order of letters in frame/axis labels

Posted 4 days ago

I have a simple plot for which I want to italicize the label of the variable in each axis label and keep the unit nonitalic. The x-axis label is A (v) and the y-axis label is R (k) where A and R are the variables that I want to italicize and v and k are the units that I want to keep nonitalic. So I did the following:

list = Table[{i, i}, {i, 6}]; ListPlot[list, PlotStyle -> {Red, Blue}, PlotRange -> All, Frame -> {True, True, False, False}, FrameLabel -> {Style[Style["A", Italic]  "(v)", Black, 24],Style[Style["R", Italic] "(k)", Black, 24]}, Axes -> False,ImageSize -> 700, FrameTicksStyle -> Directive[Black, 24]]

The x-axis label is printed out in the correct order A (v), however in the y-axis label the unit (k) appears before the variable R and I think it is because of the alphabetic order of the letters. How can I keep the order of the letters as I want them to appear?

Thanks

POSTED BY: Eft Rsd
3 Replies

It might be worth pointing out that typing expressions next to each other is the same as multiplying them in WL:

Style["R", Italic] "(k)"

Is the same as:

Times[ Style["R", Italic] ,  "(k)" ]

You can always use FullForm to see the complete syntax:

FullForm[Style["R", Italic] "(k)"]
(*  Times["(k)", Style["R", Italic]]  *)

You were wondering about the change in order. Times[] sorts its arguments into a standard order. Multiplication is commutative, so it is assumed that the order does not matter anyway. Plus[] does the same by the way. The attribute in Attributes[Times] that gives it this property is Orderless. (The attribute Flat gives it the associative property.) These properties mean that algebraic expressions are automatically arranged into a canonical form, and that makes it easier to do computational symbolic algebra.

POSTED BY: Michael Rogers
Posted 4 days ago

You could use Row for this. So, for your A(v), you could do something like

Row[{Style["A", Italic], "(v)"}, BaseStyle -> {Black, 24}]

The full FrameLabel option would look like this

FrameLabel -> {Row[{Style["A", Italic], "(v)"}, BaseStyle -> {Black, 24}], 
               Row[{Style["R", Italic], "(k)"}, BaseStyle -> {Black, 24}]}
POSTED BY: Eric Rimbey
Posted 1 day ago

It worked! Thank you a lot.

POSTED BY: Eft Rsd
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract