# ListContourPlot axis label

I want to have the correct labelling of axes in a ListContourPlot that I create via

testTable=Table[x + y, {x, 0, 5}, {y, -5, 5}];

Show[ListContourPlot[testTable,DataRange -> {{0, 5}, {-5, 5}},FrameLabel -> {"x", "y"},PlotLegends -> Automatic]


However, I want to have the correct labelling: i.e. 0<x<5 and -5<y<5. How can I do this?

Update:

However, this cannot be correct as e.g. for x->3, y->4 : x+y=-1 !

• testTable = Table[x + y, {x, 0, 5}, {y, -5, 5}]; Show[ListContourPlot[testTable, DataRange -> {{0, 5}, {-5, 5}}, PlotRange -> All]] Commented Sep 23, 2020 at 11:09
• This does not make it correct? Please see my update. Commented Sep 23, 2020 at 11:31
• testTable = Table[x + y, {x, 0, 5}, {y, -5, 5}]; ListContourPlot[Thread@testTable, DataRange -> {{0, 5}, {-5, 5}}, FrameLabel -> {"x", "y"}, PlotLegends -> Automatic, AspectRatio -> Automatic] Commented Sep 23, 2020 at 11:50

Your question's title refers to "axis label" which probably caused many to focus on the FrameTicks. However, I suspect your question actually has to do with the Contours.

Clear["Global*"]

testTable = Table[x + y, {x, 0, 5}, {y, -5, 5}];


If you do not like the default FrameTicks you must specify your own.

yTicks = DeleteDuplicatesBy[
Join[
Table[{y, ToString[y], {0.012, 0.}, {GrayLevel[0.],
AbsoluteThickness[0.4]}}, {y, -5, 5}],
Table[{y, "", {0.009, 0.}, {GrayLevel[0.],
AbsoluteThickness[0.3]}}, {y, -5, 5, 1/2}]],
First];


If you are not adding options to an existing graphic or combining graphics there is no need for Show.

EDIT: From the documentation, "ListContourPlot[array] arranges successive rows of array up the page, and successive columns across." Consequently, your data should be transposed.

ListContourPlot[Transpose@testTable,
DataRange -> {{0, 5}, {-5, 5}},
FrameLabel -> {"x", "y"},
PlotLegends -> Automatic,
FrameTicks -> {{yTicks, yTicks /. _String :> ""}, {Automatic, Automatic}}]


Compare with

ContourPlot[x + y, {x, 0, 5}, {y, -5, 5},
PlotLegends -> Automatic]


ListContourPlot[testTable,
DataRange -> {{0, 5}, {-5, 5}},
FrameLabel -> {"x", "y"},
FrameTicks -> {{ChartingScaledTicks["Linear"][-5, 5, {10, 5}], Automatic},
{Automatic, Automatic}},
PlotLegends -> Automatic]


In general, you can use ChartingScaledTicks["Linear"] as

ChartingScaledTicks["Linear"][min, max, {maxnumberofmajorticks, maxnumberofminorticks}]