How to change the scale of a ListContourPlot to logarithmic and combine it with a LogLinearPlot

My questions are:

1) how can I change the compressed scale to fine one like {y = 0.1, 1, 10}, {x = 0.01, 0.1, 1, 10, 100}.

data = Flatten[
Table[
{x, y, Sin[3 x] + Cos[3 y]},
{x, .1 Pi, 2 Pi, .2}, {y, .01 Pi, 2 Pi, .2}
],
1
];

pdata = ListContourPlot[data, Mesh -> None, PlotRange -> All, InterpolationOrder -> 3];

ticks = FrameTicks /. AbsoluteOptions[pdata, FrameTicks];

logticks = Apply[If[#1 == 0, {#1, , ##3}, {Log[10, #1], ##2}] &, ticks, {2}];

ListContourPlot[{Log[10, #1], Log[10, #2], #3} & @@@ data,
Mesh -> None, PlotRange -> All, InterpolationOrder -> 3,
ColorFunction -> ColorData[{"LakeColors", "Reverse"}],
FrameTicks -> logticks]


2) how can I combine two plots in one figure. The two plots are a ListContourPlot and LogLinearPlot.

This is my figure with Michael E2 code.

I want to plot a curve

LogLinearPlot[1 + 0.5/xx^0.33, {xx, 0.01, 105}, PlotStyle -> Red]


on the figure without any change in figure

• Whenever possible, questions should be written with a minimal code example in the post, and avoid links to external files - not just for security reasons but also because those links almost invariably go bad after a while, making the question unclear to future readers.
– Jens
Jul 11 '15 at 16:34
• Any help!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Jul 11 '15 at 19:14
• Shabaan, I see that your code comes from this answer: mathematica.stackexchange.com/a/35038/27951. Unfortunately, however, as mentioned in the comments to that answer as well, AbsoluteOptions has been essentially abandoned by WRI and doesn't work properly anymore. You may notice that it fails to extract the ticks, so your ticks variable is a list of empty lists; consequently logticks doesn't make sense either. That solution simply won't work. You could look at the alternative solution proposed in the same post instead. Jul 11 '15 at 21:30
• I need List contour plot with good logarithmic scale! Jul 12 '15 at 1:04

For the first question, you can do this:

ListContourPlot[MapAt[Log, data, {All, ;; 2}],
Mesh -> None, PlotRange -> All, InterpolationOrder -> 3,
ColorFunction -> ColorData[{"LakeColors", "Reverse"}],
FrameTicks -> {{ChartingScaledTicks[{Log, Exp}],
ChartingScaledFrameTicks[{Log,
Exp}]}, {ChartingScaledTicks[{Log, Exp}],
ChartingScaledFrameTicks[{Log, Exp}]}}]


Notes: (1) I changed Log10 to Log -- it must match the functions in ChartingScaledFrameTicks, something I overlooked initially. (2) Also, if you have V9+, MapAt[Log, data, {All, ;; 2}], which was pointed out by Mr.Wizard, is more efficient than {Log@#1, Log@#2, #3} & @@@ data and perhaps a little clearer; otherwise, stick to the @@@ form.

For the second question, plots can be combined with Show. Perhaps something like this is what is sought:

Show[
ListContourPlot[
MapAt[Log, data, {All, 1}] (* {Log@#1, #2, #3}& @@@ data *),
Mesh -> None, PlotRange -> All, InterpolationOrder -> 3,
ColorFunction -> ColorData[{"LakeColors", "Reverse"}],
FrameTicks -> {{Automatic,
Automatic}, {ChartingScaledTicks[{Log, Exp}],
ChartingScaledFrameTicks[{Log, Exp}]}}],
LogLinearPlot[3 + 2 Sin[x], {x, .1 Pi, 2 Pi}, PlotStyle -> Red]
]


• Consider using MapAt[Log10, data, {All, ;; 2}] in place of {Log[10, #1], Log[10, #2], #3} & @@@ data Jul 12 '15 at 6:05
• @Mr.Wizard Yep, if I had considered refactoring the OP's code at all, that's probably what I would have done. Thanks. Jul 12 '15 at 6:12
• This code give the following message MapAt::psl: Position specification {All,1;;2} in MapAt[Log10,{{0.314159,0.0314159,1.80458},{0.314159,0.231416,1.57755},<<47>>,{0.514159,3.43142,0.354367},<<910>>},{All,1;;2}] is not an integer or a list of integers. >> Jul 12 '15 at 9:42
• For the second question: I have LogLinearPlot give to me curve I want to plot it above the contour figure Jul 12 '15 at 9:45
• @Shaaban Ah, you must have V8 or earlier, perhaps? That form of Map was introduced in V9, I believe. -- Re 2nd Q: Is the contour figure a regular linear-linear plot that needs converting to log-linear? It should be able to be converted to log-linear with {Log@#1], #2, #3} & @@@ data and using {Automatic, Automatic} for the second pair of the FrameTicks option. Jul 12 '15 at 13:11

Although tick locations and values cannot be extracted from pdata using AbsoluteOptions, they can nonetheless be extracted.

tckx = Table[{Log[10, i], i}, {i,
Ceiling@Min@Cases[pdata[[1, 1]], {z_, _} -> z, Infinity],
Floor@Max@Cases[pdata[[1, 1]], {z_, _} -> z, Infinity]}];
tcky = Table[{Log[10, i], i}, {i,
Ceiling@Min@Cases[pdata[[1, 1]], {_, z_} -> z, Infinity],
Floor@Max@Cases[pdata[[1, 1]], {_, z_} -> z, Infinity]}];


and then included in the plot, as desired.

ListContourPlot[{Log[10, #1], Log[10, #2], #3} & @@@ data,
Mesh -> None, PlotRange -> All, InterpolationOrder -> 3,
ColorFunction -> ColorData[{"LakeColors", "Reverse"}],
FrameTicks -> {{tcky, None}, {tckx, None}}]


FYI, pdata[[1, 1]] is the internal list of points from which pdata is constructed. In this particular case, tckx and tcky are the same:

tckx // N
(* {{0., 1.}, {0.30103, 2.}, {0.477121, 3.},
{0.60206, 4.}, {0.69897, 5.}, {0.778151, 6.}} *)


Alternative Approach

Alternatively, do not use pdata at all. Instead, define

tck[min_, max_] := Table[{Log[10, i], i}, {i, Ceiling[10^min], Floor[10^max]}]


in which case

ListContourPlot[{Log[10, #1], Log[10, #2], #3} & @@@ data,
Mesh -> None, PlotRange -> All, InterpolationOrder -> 3,
ColorFunction -> ColorData[{"LakeColors", "Reverse"}],
FrameTicks -> {{tck, None}, {tck, None}}]


produces the same plot as before.

• Consider using MapAt[Log10, data, {All, ;; 2}] in place of {Log[10, #1], Log[10, #2], #3} & @@@ data` Jul 12 '15 at 6:06
• @Mr.Wizard Certainly, your option works well. What are the tradeoffs from your perspective. Jul 12 '15 at 6:15
• Mostly just brevity. :-) Jul 12 '15 at 6:50