0
$\begingroup$

I am plotting the data from a sensor; the vertical axis shows the force F, and the horizontal axis corresponds to time. I would like to have a secondary vertical axis showing the acceleration a (related by the famous equation F=ma, where m is the probe's mass).

As far as I understand, this can be easily done by the function Charting`ScaledTicks, but I can't find enough documentation to understand how to use it. Any direction would be highly appreciated.

Edit: I'm including an implementation based on @Daniel Huber's code, but it is not handling the secondary axis properly since some of the ticks are out of the range of the original plot.

d1 = Table[3 Sin[p], {p, 0, 2 Pi, Pi/10}];
mass = 0.5;
FrameTicksForForce = {-3, -2, -1, 0, 1, 2, 3};
FrameTicksForAcceleration = FrameTicksForForce/mass;

ListLinePlot[d1, Frame -> True, 
 FrameTicks -> {{FrameTicksForForce, FrameTicksForAcceleration}, 
   Automatic}, 
 FrameLabel -> {{"Force [N]", 
    "Acceleration [m/\!\(\*SuperscriptBox[\(s\), \(2\)]\)]"}, {"Time \
[s]", None}}]

enter image description here

$\endgroup$
4
  • 1
    $\begingroup$ Post your data (or at least a representative sample of the data) and the code (InputForm) that you have used. $\endgroup$
    – Bob Hanlon
    Jul 27 at 21:41
  • $\begingroup$ The curve of the acceleration will be identical to the force with the exception of a scale factor equal to the mass $\endgroup$ Jul 28 at 16:00
  • $\begingroup$ @DanielHuber I know that, thanks for the reminder. I want to add a secondary axis showing the proper acceleration units. $\endgroup$ Jul 28 at 17:22
  • $\begingroup$ I added an example for 2 axes using "Frame" $\endgroup$ Jul 28 at 18:15

1 Answer 1

1
$\begingroup$

Here is an arbitrary example for 2 curves with different units and different y axes:

d1 = Table[Sin[p], {p, 0, 2 Pi, Pi/10}];
d2 = 2 d1;

ListLinePlot[{d1, d2}, PlotRange -> {-Pi, Pi}, Frame -> True, 
 FrameTicks -> {{{-3, -2, -1, 0, 1, 2, 3}, {-Pi, -Pi/2, 0, Pi/2, Pi}},
    Automatic}]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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