Two Axes, One plot

Charting`FindTicks

You can also use Charting`FindTicks to get the linearly scaled ticks:

ListPlot[TEMPvsTIME, Joined -> True, Frame -> True,
 FrameTicks -> {{Automatic,   Charting`FindTicks[{0, 100}, {32, 212}]}, 
   {Automatic,  Charting`FindTicks[{0, 1}, {0, 60}]}},
 FrameLabel -> {{"Temp (C)", "Temp (F)"}, {"Time (hr)", "Time (min)"}}]

enter image description here

Update: If you wish to have the same positions but different labels for axes pairs (as suggested by Jose in a comment) you can do

cft = Charting`FindTicks[{0, 1}, {0, 1}];
ListPlot[TEMPvsTIME, Joined -> True, Frame -> True,
 FrameTicks -> {{cft,
    Replace[cft[##], {x_?NumericQ, Except[""], z___} :> {x,  32 + 9/5 x, z}, 1] &},
  {cft,  Replace[cft[##], {x_?NumericQ, Except[""], z___} :> {x, Floor[60  x], z}, 1] &}},
 FrameLabel -> {{"Temp (C)", "Temp (F)"}, {"Time (hr)",  "Time (min)"}}]

enter image description here

Update 2: To add GridLines (thanks @JoseAntonioDiazNavas for the suggestion) and quantity units in temperature labels (as in egwene sedai's answer):

ListPlot[TEMPvsTIME, Joined -> True, Frame -> True, 
  FrameTicks -> {{Replace[cft[##], {x_?NumericQ, Except[""], z___} :> 
     {x, Quantity[x, "Celsius"], z}, 1] &, 
    Replace[cft[##], {x_?NumericQ, Except[""], z___} :>
     {x,  UnitConvert[Quantity[x, "Celsius"], "Fahrenheit"], z},  1] &}, 
   {cft, Replace[cft[##], {x_?NumericQ, Except[""], z___} :> {x, Floor[60 x], z}, 1] &}}, 
   FrameLabel -> {{"Temp (C)", "Temp (F)"}, {"Time (hr)",  "Time (min)"}}, 
  GridLines -> {Automatic, (DeleteCases[cft[##], {_, "", ___}][[All, 1]] &)}]

enter image description here


You can use FrameTicks to specify the kind of ticks you want. I like using Charting`ScaledTicks to specify ticks, so the following would be my approach:

ListPlot[
    TEMPvsTIME,
    Joined->True,
    Frame->True,
    FrameTicks->{
        {Automatic,Charting`ScaledTicks[{5/9(#-32)&,9/5#+32&}]},
        {Automatic,Charting`ScaledTicks["Linear",{#/60&,# 60&},"Nice"]}
    },
    FrameLabel->{{"Temp (C)", "Temp (F)"},{"Time (hr)", "Time (min)"}}
]

enter image description here


You may use the SciDraw Package:

Needs["SciDraw`"];

SeedRandom[95];
TEMPvsTIME = {Range[100], 
    Accumulate[RandomReal[{-1, 1}, 100]]}\[Transpose];


ListPlot[TEMPvsTIME, Joined -> True, Frame -> True, 
 FrameLabel -> {{"Temp (C)", "Temp (F)"}, {"Time (hr)", 
    "Time (min)"}}, 
 FrameTicks -> {{LinTicks[0, 6, 1, 2], 
    LinTicks[0, 6, 1, 2, 
     TickLabelFunction -> (UnitConvert[Quantity[#, "Celsius"], 
         "Fahrenheit"] &)]}, {LinTicks[0, 100, 20, 2], 
    LinTicks[0, 100, 20, 2, TickLabelFunction -> (#*60 &)]}}]

enter image description here

Tags:

Plotting