# Changing axes units

I have plotted a graph in mathematica, where the x axis is in seconds. I want to scale the axis so it displays years instead.

My plotting function is as follows:

Plot[sol1[t], {t, 0, 1 * 10^(16)},
PlotRange -> All
FrameLabel -> {"Time (s)", "Velocity (ms-1)"},
PlotStyle -> {Red, Thickness[0.01]}]


Any help would be appreciated.

An alternative approach is to change the option value for FrameLabel and use FrameTicks with custom ticks:

sol[t_] := 1 + Sinc[10^-15   Pi t];

Plot[sol[t], {t, 0, 10^16},
Frame -> True,  ImageSize -> Large, PlotStyle -> {Red, Thickness[0.01]},
FrameLabel -> {"Time (s)", "Velocity (ms-1)"}] year = 60 60 24 365;

fticks = {{Automatic, Automatic}, {ChartingFindTicks[{0, 1}, {0,  1/year}], Automatic}};

Plot[sol[t], {t, 0, 10^16},
Frame -> True, ImageSize -> Large, PlotStyle -> {Red, Thickness[0.01]},
FrameLabel -> {"Time (year)", "Velocity (ms-1)"},
FrameTicks -> fticks] • Thank you! This is exactly what I was looking for. Is there a documentation page explaining how ChartingFindTicks works, for example if I want to scale the y axis? I'm very new to Mathematica and not had much luck finding it. – testing09 Nov 29 '20 at 14:10
• @testing09, the (undocumented) function ChartingFindTicks[{a, b}, {c, d}][min, max] generates the major and minor ticks based on the automatically computed minimum and maximum of the values on the axis using the scaling parameters {a, b}, {c, d} for computing the labels for major ticks. I think the way it works is ... – kglr Nov 30 '20 at 18:32
• ... as follows: First, FindDivisions is used with inputs min, max and, some hard-coded parameter for the number of major and minor ticks ticks (which, I guess, is {6,6}) to compute major and minor ticks; then, for major tick t, Rescale[t, {a,b}, {c,d}] is used to compute the tick label for t. – kglr Nov 30 '20 at 18:33

For illustration purposes let sol1 be

sol1[t_] = Exp[-3*^-16 t];


The original plot

Plot[sol1[t], {t, 0, 1*10^(16)}, PlotRange -> All,
Frame -> True, FrameLabel -> {"Time (s)", "Velocity (ms-1)"},
PlotStyle -> {Red, Thickness[0.01]},
ImageSize -> Medium] The average number of seconds in a year

yr = QuantityMagnitude@UnitConvert[Quantity[1, "Years"], "Seconds"]

(* 31536000 *)


The rescaled plot

Plot[sol1[t*yr], {t, 0, 10^16/yr},
PlotRange -> All,
Frame -> True,
FrameLabel -> {"Time (yr)", "Velocity (ms-1)"},
PlotStyle -> {Red, Thickness[0.01]},
ImageSize -> Medium]
` 