How does one set a logarithmic scale in a ContourPlot?
One possibility is to plot the contour plot with linear scales using ContourPlot
and use ListLogLogPlot
to transform this plot to one with logarithmic scales:
pl = Normal@
ContourPlot[
Sin[3 x] + Cos[3 y] == 1/2, {x, .01 Pi, 3 Pi}, {y, .01 Pi, 3 Pi},
PlotPoints -> 30]
ListLogLogPlot[Cases[pl, Line[a_, b___] :> a, Infinity],
Joined -> True, Frame -> True, PlotRange -> All, AspectRatio -> 1,
PlotStyle -> ColorData[1][1]]
Instead of doing some transformation on the original ContourPlot
we can do an exponential rescaling of the original variables in the ContourPlot
, so this is somewhat different approach to get roughly the same result :
ContourPlot[ Sin[ 3 Exp@x] + Cos[ 3 Exp@y ] == 1/2,
{x, Log[0.01 Pi], Log[3 Pi]}, {y, Log[0.01 Pi], Log[3 Pi]}, PlotPoints -> 30]
The only difference is a different coordinate system.
As a slight variation of the nice suggestion above add FrameTicks
to get the tick labels you want.
ContourPlot[
Sin[3 Exp[x]] + Cos[3 Exp[y]] == 1/2, {x, Log[0.01 Pi],
Log[3 Pi]}, {y, Log[0.01 Pi], Log[3 Pi]}, PlotPoints -> 30,
FrameTicks -> {Table[{y, ToString[Round[10^y, 0.001]]}, {y,
Log[10, 0.001], Log[10, 100]}],
Table[{y, ToString[Round[10^y, 0.001]]}, {y, Log[10, 0.001],
Log[10, 100]}]}]