# Log plot and linear plot plotted in one view

I have the following code:

q := 1.6*10^-19;
me := 9.1*10^-31; (* Free electron rest mass in kg *)
h :=  6.63*10^-34;  (* Reduced Planck's constant in J.s *)
kb := 1.38*10^-23;(* Boltzmann constant in J/K *)
Jschottky[V_, T_] := (2 q*(2 \[Pi] me)^0.5 kb^1.5)/h^2*(0.3)^0.5*
Exp[-0.18/((kb*T)/q)] (Exp[(q*V)/(kb*T)] - 1);
LogPlot[Abs[Jschottky[V, 77]], {V, -0.5, 0.5}, PlotRange -> All,
Frame -> True,
FrameLabel -> {"Voltage (V)",
"\!$$\*FractionBox[\(J$$, SuperscriptBox[$$T$$, $$3/2$$]]\)"},
BaseStyle -> {FontSize -> 15}, PlotStyle -> {Thick, Red} ,
AspectRatio -> GoldenRatio, ImageSize -> 400, FrameStyle -> Black,
FrameTicks -> {{{#, Superscript[10, Log10@#]} & /@ ({10^-21, 10^-11,
10^-1, 10^9, 10^19}), None}, {Automatic, None}}]

Plot[Abs[Jschottky[V, 77]], {V, -0.5, 0.5}, PlotRange -> All,
Frame -> True,
FrameLabel -> {"Voltage (V)",
"\!$$\*FractionBox[\(J$$, SuperscriptBox[$$T$$, $$3/2$$]]\)"},
BaseStyle -> {FontSize -> 15}, PlotStyle -> {Thick, Blue} ,
AspectRatio -> GoldenRatio, ImageSize -> 400, FrameStyle -> Black]


I get the following results:

Now I want to plot them on the same plot with the logplot on the left y axis and the linear plot on the right yaxis. What should I do? Also any recommendations for a good grayscale plot of the same?

• Please supply the definition for your Jschottky function. Without it, it is impossible to work with code. Sep 26, 2020 at 18:00
• Sorry, I don't know how I missed that. I have added it. Any help is appreciated. Sep 26, 2020 at 20:57
• You probably do not want to use SetDelayed (:=) for your constant values here. You can simply use Set (=). This will avoid unnecessary evaluation time. Feb 25, 2021 at 19:12

q := 1.6*10^-19;
me := 9.1*10^-31;(*Free electron rest mass in kg*)h :=
6.63*10^-34;(*Reduced Planck's constant in J.s*)kb :=
1.38*10^-23;(*Boltzmann constant in J/K*)
Jschottky[V_, T_] := (2 q*(2 \[Pi] me)^0.5 kb^1.5)/h^2*(0.3)^0.5*
Exp[-0.18/((kb*T)/q)] (Exp[(q*V)/(kb*T)] - 1);
p1 = LogPlot[Abs[Jschottky[V, 77]], {V, -0.5, 0.5}, PlotRange -> All,
Frame -> True,
FrameLabel -> {"Voltage (V)",
"\!$$\*FractionBox[\(J$$, SuperscriptBox[$$T$$, $$3/2$$]]\)"},
BaseStyle -> {FontSize -> 15}, PlotStyle -> {Thick, Red},
AspectRatio -> GoldenRatio, ImageSize -> 400, FrameStyle -> Black,
ImagePadding -> {{100, 100}, {80, 80}}, FrameTicksStyle -> Red,
FrameTicks -> {{{#, Superscript[10, Log10@#]} & /@ ({10^-21, 10^-11,
10^-1, 10^9, 10^19}), None}, {Automatic, None}}]

p2 = Plot[Abs[Jschottky[V, 77]], {V, -0.5, 0.5}, PlotRange -> All,
Frame -> True,
FrameLabel -> {{None,
"\!$$\*FractionBox[\(J$$, SuperscriptBox[$$T$$, $$3/2$$]]\)"}, \
{None, None}}, BaseStyle -> {FontSize -> 15},
PlotStyle -> {Thick, Blue}, AspectRatio -> GoldenRatio,
ImageSize -> 400, ImagePadding -> {{100, 100}, {80, 80}},
FrameStyle -> Black, FrameTicks -> {{None, All}, {None, None}},
FrameTicksStyle -> Blue]
Overlay[{p1, p2}]


• Thanks! How should I make the x-axis to be black in color? Sep 27, 2020 at 14:04
• For p1, use FrameTicksStyle -> {{Red, None}, {None, Black}}. This sets the color for {{left,right},{top,bottom}}. Sep 27, 2020 at 14:14

On a side note (but too big to fit in a comment), you can speed up the Jschottky function evaluation by about 13x by using FunctionCompile:

f = Function[{Typed[V, "Real64"], Typed[T, "Integer64"]},
Module[{q, me, h, kb},
q = 1.6*10^-19;
me = 9.1*10^-31;
h = 6.63*10^-34;
kb = 1.38*10^-23;
(2 q*(2 \[Pi] me)^0.5 kb^1.5)/h^2*(0.3)^0.5*
Exp[-0.18/((kb*T)/q)] (Exp[(q*V)/(kb*T)] - 1)
]
]


and then:

cf = FunctionCompile[f]


On my machine I get the following timings:

In[.]:= Do[Jschottky[RandomReal[{-0.5, 0.5}], 77], 100000] // AbsoluteTiming
Out[.]= {0.777224, Null}

In[.]:= Do[cf[RandomReal[{-0.5, 0.5}], 77], 100000] // AbsoluteTiming

Out[.]= {0.0563924, Null}

• Thank you, what all functions does it work for? And what are you actually doing by executing it this way? Feb 26, 2021 at 16:07
• Almost everything I know is contained in this presentation by Tom Wickham-Jones. It's worth watching! youtube.com/watch?v=LulZszTJH4g Feb 26, 2021 at 18:18