Group Abstract Group Abstract

Message Boards Message Boards

0
|
6.8K Views
|
10 Replies
|
0 Total Likes
View groups...
Share
Share this post:

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

Posted 5 years ago

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.

![][1]

Attachment

10 Replies

Many thanks for sharing this, Rohit!

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.

POSTED BY: Henrik Schachner
Posted 5 years ago
POSTED BY: Rohit Namjoshi

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

POSTED BY: Ian Williams

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!

Attachment

Attachments:
Posted 5 years ago

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?

POSTED BY: Rohit Namjoshi

Thanks for reminding! I have now attached my notebook.

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.

enter image description here

POSTED BY: EDITORIAL BOARD
Posted 5 years ago

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}}]

enter image description here

POSTED BY: Rohit Namjoshi
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard