# Showing real scale of the x-axis of a plot beside the axis label

I am using the code shown below to plot simple functions in which I am going to show the horizontal axes just with integer numbers. For correct presentation, I want to bring * π/2 beside the axes, as also shown below. But I have put * π/2 in the AxesLabel close to the t parameter. I am uncertain about the correctness of making the presentation this way. In fact, I do not know how I must show the exact scale of the horizontal axes when I want to present just integers on the ticks of plot. Any advice?

Plot[{Sin[x], Cos[x]}, {x, 0, 5 π/2},
AxesLabel -> {Style["*π/2 t", Bold, 11], Style["C", Bold, 11]},
LabelStyle-> {Bold, 11},
Ticks-> {{{1Pi/2, Style["1"]},{3Pi/2, Style["3"]}, {5Pi/2, Style["5"]}}}];


• Wouldn't it be much better to include the $\pi/2$ factor in your axis tick labels? It would improve readability, at least in my opinion (i.e. Ticks -> {{{Pi/2, Style["π/2"]}, {3 Pi/2, Style["3π/2"]}, {5 Pi/2, Style["5π/2"]}}}) to give this. May 4, 2018 at 18:03
• thanx. maybe!!! May 4, 2018 at 18:14

This turned out to be harder than I originally thought it would. The problem is that the x-axis is showing ticks for t, not the plotting variable x, so it is important that the relation between t and x be clearly shown. Further, the OP requested that the information about the relationship be displayed as an x-axis label. That condition caused trouble. I found I couldn't use the option PlotLabels to label the two curves because Mathematica insisted on overwriting the x-axis label with the cosine curve label. I had to resort to using callouts with some explicit positioning.

Plot[
{Callout[Sin[x], Sin[x]], Callout[Cos[x], Cos[x], {5 π/2 + 1.2, .6}]},
{x, 0, 5 π/2},
LabelStyle -> {Bold, 12},
AxesLabel -> {Row[{t, ", ", HoldForm[x = π/2], "\[ThinSpace]", t}], "C"},
Ticks -> {{# π/2, #} & /@ Range[1, 5, 2], Automatic},
ImageSize -> 500]


The above conforms to my understanding of what the OP is asking for, but for myself I wouldn't make the plot that way. I would make it like this:

Plot[
{Callout[Sin[π t/2 ], Sin[π t/2 ]], Callout[Cos[π t/2], Cos[π t/2], {5 + .9, .4}]},
{t, 0, 5},
LabelStyle -> {Bold, 11},
AxesLabel -> {"t", "C"},
ImageSize -> 500]


I believe the second plot gets the point across better with simpler code. That's two pluses.

### Update

I was really unhappy that I had not been able to post a solution using PlotLabels and Placed, so I returned to this problem, spent some time reading the documentation more carefully and trying this and that. After going down some wrong paths, I finally found a way.

Plot[{Sin[x], Cos[x]}, {x, 0, 5 π/2},
LabelStyle -> {Bold, 12},
AxesLabel -> {Row[{t, ", ", HoldForm[x = π/2], "\[ThinSpace]", t}], "C"},
Ticks -> {{# π/2, #} & /@ Range[1, 5, 2], Automatic},
PlotLabels ->
Placed["Expressions", {{Scaled[.2], Above}, {Scaled[.82], Above}}],
ImageSize -> 500]


The trick is to give the 2nd argument to Placed, the position specifier, as a list of two elements, one for each curve. Each element should be a pair of the form {offset, position}, where offset is a scaled distance along the x-axis and position indicates where the label should be positioned relative to curve at the offset (the usual Above, Before, etc.). This is never explicitly stated in the documentation, but there is an example of a list plot that hints at this solution.