Is there any way to overwrite the x-axis values in a plot?
I have numerical solution to a differential equation, the solution is plotted against time in seconds. However, I want to change the x-scale of my plot to show minutes, without having to go back and solve the differential equation again.
Plot[Evaluate[(((y[x]) /. solutionNum))], {x, 0, signalLength},
PlotRange -> {{0, signalLength}, {All, All}},
FrameLabel -> {"time / s", "temperature / ºC" }, PlotLegends -> {"Model"}];
I want to overwrite the x-axis values to show for instance 0-250 minutes, and not 0-15000 seconds, without having to redo my soluton .
Thanks in advance!
sghuisman
(Sander Huisman)
March 29, 2017, 2:49pm
2
Rescaling of your variable x:
Plot[Evaluate[(((y[60x]) /. solutionNum))], {x, 0, signalLength/60}, PlotRange -> {{0, signalLength}, {All, All}}, FrameLabel -> {"time / min", "temperature / ºC" }, PlotLegends -> {"Model"}];
would do the trick, without the data it is tricky to test..
christopher
(Christopher Wolfram)
March 29, 2017, 10:14pm
3
If you are using the Quantity system, you should be able to use an option called TargetUnits.
neils
(Neil Singer)
March 31, 2017, 3:09pm
4
Sara,
I like to use TimeSeries because you can shift and scale things later (if you need to compare real data, etc.).
Using the example from NDSolve:
s = NDSolve[{y'[x] == y[x] Cos[x + y[x]], y[0] == 1}, y, {x, 0, 30}][[1]]
The answer is in seconds so I construct a TimeSeries from it that has minute spacing:
ListLinePlot[TimeSeries[(y /. s)[Range[0, 30, .1]], {0, 30/60}],
PlotRange -> All]
to get:
That will be really helpful for me also in other projects. Thanks a lot!