2
$\begingroup$

Frequently for convenient experimental data analysis it is necessary to present results with two vertical axes in the same plot with different scale and distance between ticks.

I've tried to find solutions to this issue, but there aren't adequate ways to realize this.

  1. Overlay[{ListLogLinearPlot[...], ListLogLinearPlot[...]}] doesn't work properly and moreover doesn't allow to use it like a template.
  2. TwoAxisPlot is not appropriate because of need compatibility with CustomTicks package.

//CustomTicks package allows to determine accurately position of minor and major LogTicks or LinTicks.

Are there other ways to implement this?

Thanks in advance.

Here is the code.

Show[ListLogLinearPlot[data[[3]], PlotRange -> {{10^1.3, 10^6}, {738.35, 738.65}}, 
  PlotStyle -> {Orange, PointSize[0.015]}, Frame -> True, 
  FrameLabel -> {"Var_1, a.u.", "Var_2, a.u.", None, None},
  LabelStyle -> {FontSize -> 15, FontFamily -> "Helvetica", Black},
  FrameStyle -> Thickness[0.001], 
  FrameTicksStyle -> Thickness[0.001],
  FrameTicks -> {{LinTicks[CMj, CMn], None}, {LogTicks, None}}], 
 ImageSize -> 600]

enter image description here

$\endgroup$
4
  • 2
    $\begingroup$ You did not provide the data, but you should have a look at the resource function CombinePlots. $\endgroup$
    – Tim Laska
    Sep 11, 2020 at 18:00
  • 1
    $\begingroup$ The second vertical scale can be implemented with the FrameTicks option. See this recent question and its answers for examples. $\endgroup$
    – LouisB
    Sep 11, 2020 at 20:03
  • $\begingroup$ @Tim Laska, doesn't matter what data it is. Thanks for link. $\endgroup$
    – Alex
    Sep 12, 2020 at 18:51
  • $\begingroup$ You are supposed to provide minimal working example so the potential helpers do not need to divine your intent. $\endgroup$
    – Tim Laska
    Sep 12, 2020 at 21:14

1 Answer 1

3
$\begingroup$

You can do that by combinning the two plots using CombinePlots

 ResourceFunction["CombinePlots"][
 Plot[x, {x, 0, 10}, Frame -> True, 
  FrameLabel -> {"common axis", "Scale-1", None, None}], 
 Plot[ Sin[x], {x, 0, 10}, Frame -> True, FrameStyle -> Red, 
  PlotStyle -> Red, 
  FrameLabel -> {"common axis", "Scale-2", None, None}], 
 "AxesSides" -> "TwoY"]

enter image description here

Update

Now, assume that we have a data that we want to represent with two different scales, say the scale factor is f, then we can still do that as follows

      ResourceFunction["CombinePlots"][
 ListLinePlot[Table[{x, 10 x}, {x, 0, 10}], Frame -> True, 
  PlotStyle -> Black, 
  FrameLabel -> {"common axis", "Scale-1", None, None}, 
  FrameStyle -> {Directive[{Blue, FontFamily -> "Times", 15}], 
    Directive[{Black, FontFamily -> "Times", 15}]}], 
 ListLinePlot[ Table[{x, f 10 x} /. f -> 0.1, {x, 0, 10}], 
  Frame -> True, PlotStyle -> None, 
  FrameLabel -> {"common axis", "Scale-2", None, None}, 
  FrameStyle -> Directive[{Red, FontFamily -> "Times", 15}]], 
 "AxesSides" -> "TwoY"]

here I considered that the scaling factor is f=1/10
enter image description here

$\endgroup$
3
  • 1
    $\begingroup$ In this case, the scales correspond to the plots for which they are similarly colored. What OP has asked for is not this. It would be better if you showed how to use CombinePlots with only one set of data, but two separate scales on the axes, as the OP has asked for—can you clarify how to do this? $\endgroup$ Sep 12, 2020 at 14:25
  • 1
    $\begingroup$ @CATrevillian, thanks for the explanation, I updates my answer $\endgroup$ Sep 12, 2020 at 15:18
  • $\begingroup$ This way is good. Thanks, @HD2006! $\endgroup$
    – Alex
    Sep 12, 2020 at 18:48

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.