# Confused about the axis labels of ListDensityPlot

I'm not really familiar wih ListDensityPlot and for example I have the following code

ListDensityPlot[Table[N[Sin[x]*Cos[y]], {x, 0, 5}, {y, 2, 7}], PlotLegends -> Automatic, PlotRange -> Full, ColorFunction -> ColorData["SolarColors"]]


What is in the x and y axis? And why is the x axis numbered from 1 to 6 and not 0 to 5. The same for the y axis, why is it also numbered from 1 to 6 and not 2 to 7?

• Try ListDensityPlot[Flatten[Table[{x,y,N[Sin[x]*Cos[y]]}, {x, 0, 5}, {y, 2, 7}],1], PlotLegends -> Automatic, PlotRange -> Full, ColorFunction -> ColorData["SolarColors"]] . You need to use a three column array for ListDensityPlot. – Sumit Nov 5 '17 at 13:59
• @Sumit beat me to it, except I'd use Catenate rather than the more Flatten[..., 1]. You could also (less cleanly, IMO) use DataRange->{{0,5},{2,7}}. – jjc385 Nov 5 '17 at 14:01

In short ListDensityPlot like other ListPlot variants uses the index of the value of the array for the axes ticks unless it is otherwise specified.

If you wanted it to plot with the coordinates you passed there are several ways. One way is to add the option DataRange -> {{2, 7}, {0, 5}} to ListDensityPlot. Note that with how you have constructed your table, your $y$ coordinate is on the $x$-axis.

An alternative way is to include the coords in the data with something like

Flatten[Table[{x, y, N[Sin[x]*Cos[y]]}, {x, 0, 5}, {y, 2, 8}], 1]


Flatten[Table[{x, y, N[Sin[x]*Cos[y]]}, {x, 0, 5}, {y, 2, 8}], 1]

You have to flatten the array in this case because of what ListDensityPlot is able to interpret.