# How to generate data in a given format?

I have a matrix containing data points that I would like to plot and scale. Specifically, I want to generate a surface with random values on the order of 1 micrometer. I have attempted to plot it using the codes

       MatrixPlot[data] and ListDensityPlot[data],


but neither of them are working properly. Please provide guidance on how to plot and scale this data correctly.

Plot of generated data should looks like this type .

• e.g., data=RandomReal[{-1, 1}, {10, 3}] This generates 10 random points with all values between -1 and +1. Try: ListPlot3D[data].
– Syed
Jun 17, 2023 at 4:44
• Thank you, Syed. take a look at the data in the provided link. Could you please provide me with the code that can generate data points in that template? Jun 17, 2023 at 6:50
– Syed
Jun 17, 2023 at 7:03

Let's work from the image of your data. We need the $$x$$ and $$y$$ coordinates, and the values for $$z$$. We rearrange the data as $$((x_1,y_1,z_{11}),(x_2,y_1,z_{21}),\ldots,(x_6,y_6,z_{66}))$$.

x = Quantity[{-15.187, -15.068, -14.949, -14.831, -14.712, -14.593}, "Millimeters"];
y = Quantity[{15.119, 15., 14.881, 14.762, 14.643, 14.524}, "Millimeters"];
z = Quantity[{{-5.2487, -5.2483, -5.2479, -5.2473, -5.2457, -5.246},
{-5.2477, -5.2473, -5.2459, -5.2453, -5.2456, -5.2449},
{-5.2464, -5.246, -5.2455, -5.2449, -5.2442, -5.2435},
{-5.2448, -5.2444, -5.2439, -5.2433, -5.2425, -5.2418},
{-5.2431, -5.2425, -5.2421, -5.2414, -5.2407, -5.2399},
{-5.2412, -5.2407, -5.2402, -5.2395, -5.2387, -5.2379}}, "Micrometers"];

dataxyz = Transpose[{Flatten[ConstantArray[x, Length@y]],
Flatten[Transpose[ConstantArray[y, Length@x]]],
Flatten[z]}];


Use dataxyz for three example plots.

g1 = ListPlot3D[dataxyz, AxesLabel -> Automatic, LabelStyle -> 12];
g2 = ListContourPlot[dataxyz, FrameLabel -> Automatic, LabelStyle -> 14];
g3 = ListDensityPlot[dataxyz, FrameLabel -> Automatic, LabelStyle -> 14];

GraphicsRow[{g1, g2, g3}, ImageSize -> 940]


• Thanks, @creidhne, It is working for me. One more line code needs how to export dataxyz so that I can get the data format as shown in the attached picture. Jun 18, 2023 at 8:56