2

Let's consider the following simple example

Clear["Global`*"];

S0 = Plot[Sin[x], {x, -10, 10}, Frame -> True]

enter image description here

Now, I want to add a second horizontal axis (at the top of the frame) in which 1 unit of the lower axis corresponds to 5.2 units in the top axis. Any ideas?

Merry Christmas to all!

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
Vaggelis_Z
  • 8,740
  • 6
  • 34
  • 79

1 Answers1

3
Plot[Sin[x], {x, -10, 10}, Frame -> True, 
 FrameTicks -> {{Automatic, Automatic},
      {All, Charting`FindTicks[{0, 1}, {0, 5.2}][-10, 10]}}]

enter image description here

kglr
  • 394,356
  • 18
  • 477
  • 896
  • Nice! One question: why the numbers of the top axis come with a dot, e.g., 20. instead of 20 (as in the lower axis)? Is there a way to remove the dots? – Vaggelis_Z Dec 25 '19 at 13:43
  • @Vaggelis_Z, when we tick spec is a Charting`FindTicks[{0, 1}, {0, 5.2}] that function is evaluated at automatically computed min and max for associated axis. If we provide integer arguments to this function using Charting`FindTicks[{0, 1}, {0, 5.2}][-10,10] we do get integer labels. – kglr Dec 25 '19 at 14:19