Skip to main content

plotting - How to assign arbitrary values to frameaxis of a ListDensityPlot


Maybe the question is stupid or already has been asked, however, I cannot find an answer while searching Q&A.


Assume you have a


Table[x*y,{x,1,4},{y,1,4}]

Now applying ListDensityPlot will bring the values 1 to 4 to the frameaxis, which reflects somehow col and row of the table.


But how to assign arbitrary values or even a string to these frameaxis of a ListDensityPlot? Anybody can help?


MWE



Answer



For random values,



ListDensityPlot[Table[x*y, {x, 1, 4}, {y, 1, 4}], FrameTicks ->
{{Transpose[{Range[4], RandomReal[1, 4]}], Automatic},
{Transpose[{Range[4], RandomReal[1, 4]}], Automatic}}]

enter image description here


For string labels,


ListDensityPlot[Table[x*y, {x, 1, 4}, {y, 1, 4}], FrameTicks ->
{{{{1, "hello"}, {3, "world"}}, Automatic},
{{{1.5, "a"}, {3.2, "b"}}, Automatic}}]


enter image description here


Comments