1
$\begingroup$

I have a matrix of size 800x600 in which each value is basically z value. This matrix is stored in text file. I want to import the file in Mathematica and plot it as DensityPlot using ListDensityPlot. In doing so, I am able to plot the data but the x and y axis scale as 0 to 800 and 0 to 600 respectively indicating basically indices of the values stored in the matrix. But in reality I want to scale both x and y axis lets say x ranges from 0 to 4 and y ranges from 0 to 3. In other words I want to keep full scale of the plot with all the data while my frame ticks on x and y axis scaled from 0 to 4 and 0 to 3 respectively.

For example, when I import the data (here my data is matrix of size 301x201)and plot it, it looks this, here basically it takes x and y axis tick values as data indices in the matrix

Plot from importing the data

But actually, in my plot I want to change the axis tick values like this way keeping everything else as it is

Plot by evaluating the function

$\endgroup$
  • 1
    $\begingroup$ Please give us a sample of what your data might look like. $\endgroup$ – t-smart Nov 3 '18 at 12:15
0
$\begingroup$

ListDensityPlot has an option called DataRange that will scale the axis for you.

Here is some synthetic data that represents a 800 x 600 array of z-values.

data = Table[Sin[3 i/800 + (3 j/600)^2], {j, 1, 600}, {i, 1, 800}];

The default plot:

ListDensityPlot[data]

Mathematica graphics

Now use the DataRange option:

ListDensityPlot[data, DataRange -> {{0, 4}, {0, 3}}]

Mathematica graphics

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.