I look for the plotting of several curves with different vertical scales. The context is to draw in one plot the 4 curves (jerk, acceleration, velocity and displacement) of a finite jerk motion profile.

This topic has already discussed in the following post : Two vertical axes in the same plot Plot with multiple Y-axes

The second one seems to be good but it is difficult to understand and consequently to modify to adapt to my case.

Consequently, i made this small code :

ScaledPlot[fcts_, coef_, dom_, options___] :=
 Plot[Evaluate[coef*fcts], dom, 
  Evaluate[PlotLegends -> 
     Row[{##}] &, {coef, {"\[Times]\[ThinSpace]j[t]", 
       "\[Times]\[ThinSpace]a[t]", "\[Times]\[ThinSpace]v[t]", 
       "\[Times]\[ThinSpace]q[t]"}}]], options]

ScaledPlot[{j[t], a[t], v[t], q[t]}, {1/40000, 1/200, 1/10, 1}, {t, 0,
  1}, Filling -> Axis]

It is almost good but i have some discontinuities for the acceleration : enter image description here

and i think these discontinuities come from display issues. Indeed, i have no issue when i plot the acceleration curve alone (see below):

enter image description here

1) Have you some ideas to correct the discontinuities that i obtain in the display when i try to plot the 4 curves in the same plot with my method ?

2) Is there somebody interested to make the code present in this post (Plot with multiple Y-axes) more accessible so that it can be used easily ? i would like to use this code but i'm not able to do it for the moment

The code which enables me to obtain these motion profile curves was given in this post :

Finite Jerk Motion Profile

  • $\begingroup$ Providing your functions j[t], a[t], v[t], q[t] might increase the chance to get helpful answers! $\endgroup$ Nov 17, 2022 at 7:32
  • $\begingroup$ the code is quite big. The code is given here (in a former post) as i said at the end of the post : mathematica.stackexchange.com/questions/275943/… $\endgroup$
    – Bendesarts
    Nov 17, 2022 at 7:57

2 Answers 2


You can use the MultiaxisArrangement option of ListLinePlot:

  Plot[{j[t], a[t], v[t], q[t]}, {t, 0, 1}, PlotRange -> All, Exclusions -> None],
  Line@pts_ :> pts,
 MultiaxisArrangement -> All

enter image description here

Unfortunately, the option is not yet directly supported for Plot, so I extract the lines from the Plot command and replot using ListLinePlot. Also the option is still quite buggy, e.g. adding Filling->Axis leads to the same fill color for all curves:

enter image description here

Finally, note the added Exclusions->None in the plot command, this is to work around an issue in Mathematica 13.1.

  • $\begingroup$ @ interesting, and how can i do if i want than the max of acceleration be above the max of velocity so as to have better visibility $\endgroup$
    – Bendesarts
    Nov 17, 2022 at 9:08
  • $\begingroup$ @Bendesarts Unfortunately I don't think that is supported yet $\endgroup$
    – Lukas Lang
    Nov 17, 2022 at 9:18
  • $\begingroup$ Consequently the best will be to simplify the code which is accessible here : mathematica.stackexchange.com/questions/164846/… to make it accessible $\endgroup$
    – Bendesarts
    Nov 17, 2022 at 9:33

With the following option in the plot function : PlotPoints -> 1000 it works !


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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