1

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 -> 
    MapThread[
     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

Bendesarts
  • 1,099
  • 5
  • 12
  • Providing your functions j[t], a[t], v[t], q[t] might increase the chance to get helpful answers! – Ulrich Neumann Nov 17 '22 at 07:32
  • the code is quite big. The code is given here (in a former post) as i said at the end of the post : https://mathematica.stackexchange.com/questions/275943/finite-jerk-motion-profile/276134#276134 – Bendesarts Nov 17 '22 at 07:57

2 Answers2

1

You can use the MultiaxisArrangement option of ListLinePlot:

ListLinePlot[
 Cases[
  Plot[{j[t], a[t], v[t], q[t]}, {t, 0, 1}, PlotRange -> All, Exclusions -> None],
  Line@pts_ :> pts,
  All
  ],
 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.

Lukas Lang
  • 33,963
  • 1
  • 51
  • 97
  • @

    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

    – Bendesarts Nov 17 '22 at 09:08
  • @Bendesarts Unfortunately I don't think that is supported yet – Lukas Lang Nov 17 '22 at 09:18
  • Consequently the best will be to simplify the code which is accessible here : https://mathematica.stackexchange.com/questions/164846/plot-with-multiple-y-axes to make it accessible – Bendesarts Nov 17 '22 at 09:33
0

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

Bendesarts
  • 1,099
  • 5
  • 12