I am doing boxed contour plots of a quantity that depends on two variables. Let's call it f[A,B]. A will go to the lower horizontal axis, and B to the left vertical axis. I would like the two remaining axes (call them C and D) to follow known rules, i.e. the right vertical will be some known function of the left vertical axis: D=D(B), and similarly for the upper horizontal axis: C=C(A). Thanks very much.

ClearAll[f, g, h]
f[x_, y_] := Cos[x] + Cos[y]
d[x_] := 5 + 2 x
c[x_] := Log[5 x]

You can use Charting`ScaledTicks[{d, InverseFunction[d]}] to construct the ticks for the right axis and Charting`ScaledTicks[{c, InverseFunction[c]}] for the top axis:

ContourPlot[f[x, y], {x, 0, 4 Pi}, {y, 0, 4 Pi}, 
 FrameTicks -> {{Automatic, Charting`ScaledTicks[{d, InverseFunction[d]}][##] &},  
    {Automatic, Charting`ScaledTicks[{c, InverseFunction[c]}][##] &}}]

enter image description here

| improve this answer | |
  • $\begingroup$ Thank you very much! $\endgroup$ – MCV Feb 20 at 15:03
  • $\begingroup$ @MCV, my pleasure. Thank you for the accept. And welcome to mma.se. $\endgroup$ – kglr Feb 20 at 15:10

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.