How to add a secondary y axis in a plot with a single curve?

Hello! I’m trying to add a secondary y axis in a plot. This secondary y axis here is just a function of the primary y axis, but in different units, and needs to be shown only for reference. The set of curves in the plot should be the same referring to the two vertical axes. As can be seen in the image attached, I would like to combine the two vertical axes from the two plots and make it a single plot with left and right axes. I would appreciate any help regarding this.

Please see attached notebook.

Natural hybrid inflation param space.nb (66 KB)

Hi Kaustuh,

Use scaled values for the ticks on the right. e.g.

LogLogPlot[x, {x, 10^-7, 1},
 Frame -> True,
 FrameTicks -> {{Automatic, Charting`ScaledTicks[{Log[# 10^-13] &, Exp[#]/10^-13 &}]},
   {Automatic, Automatic}}]

Welcome to Wolfram Community!
Please make sure you know the rules: https://wolfr.am/READ-1ST
Please provide your code (formatted) in your post so that other members can copy and evaluate it in order to help you.

Formatted code looks like this

int = Integrate[1/(x^3 - 1), x];
Map[Framed, int, Infinity]

You can also embed notebook or attach notebook.

Thanks for reminding! I have now attached my notebook.

Hi Kaustuh,

Took a look at the notebook that you have attached now, and the method I proposed should work fine. Have you tried it?

Hi Rohit! Many thanks for your reply! Yes, the method you suggested worked for me. Below is the code edit

FrameTicks -> {{All, 
   Charting`ScaledTicks[{Log[# fOverH/MPlValueGeV] &, 
     Exp[#] MPlValueGeV/fOverH &}]}, {Automatic, None}}

generating the attached plot. Thanks a ton!

I tried searching details about this Charting`ScaledTicks function but couldn’t find any documentation. If you have that available, could you please share it? Or if not, could you briefly explain the function arguments? Thanks in advance!

There’s a function in the Function Repository that might do what you want - see MultipleAxesPlot.

This function generates two vertical axes, each corresponding to a different curve. I want both the vertical axes to correspond to the same curve.

In any case, suggestion by @Rohit Namjoshi seems to work, although I don’t fully understand how that function works.

Thanks again!

Hi Kaustuh,

Unfortunately ChartingScaledTicks</code> is an undocumented function. It has been around since version 10, and is widely used internally in WL code, so it is unlikely to be removed any time soon. In it's simplest form it take a list of two functions {f1, f2}wheref2must be the inverse function off1. f2takes a single argument, the value to be scaled and returns the scaled value,f1does the inverse. e.g. in the following plot thex` axis ticks are shown as degrees rather than radians.

Plot[Sin[x], {x, 0, Pi},
 Frame -> True,
 FrameTicks -> {Automatic, {Charting`ScaledTicks[{# Degree &, # / Degree &}], Automatic}}]

To see the more complex forms it supports

Needs["GeneralUtilities`"]
PrintDefinitions[Charting`ScaledTicks]

Hello Rohit,

great anwer - many thanks for sharing! But where on earth one can find things like Charting'ScaledTicks[...]? My search in the documentation was without any result.

Many thanks for sharing this, Rohit!