How to set scale range for a contour?

Hello,
I am trying to plot a contour from excel data with two colums. Is their any way to set the scale of both the axis in the data range and with label? I am attaching the contour plot i have obtained, I didnt understand why the x axis is from 1:2. Can some one please help me. Thanks in advance.
My code:
data = readtable('Abb73at42.xlsx');
dataArray = table2array(data);
contourf(dataArray);

 Accepted Answer

The x-axis goes from 1 to 2 because the contour plot is of a (117x2) matrix. That also explains the range of the y-axis.
data = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/736719/Abb73at42.xlsx')
data = 117×2 table
X Y _______ ______ -69.793 1.3879 -69.635 2.4547 -69.537 3.4459 -69.432 4.904 -69.352 6.4546 -69.334 7.5779 -69.161 9.0059 -68.937 10.381 -68.975 11.324 -68.975 12.41 -68.975 13.496 -68.889 14.557 -68.548 16.102 -68.435 17.943 -68.376 19.148 -68.172 20.606
figure
plot(data.X, data.Y)
grid
xlabel('X')
ylabel('Y')
More importantly, what information do you want to get from a contour plot of these data? That could provide an approach to getting a useful result.
.

5 Comments

Hello,
Thank you fro the quick response. I wanted to check the profile from the data. Is it possible to plot it as a contour as like in the figure i have uploaded with the data scale range instead of cell numbers?
With regards
No. Your desired contour requires 3 variables: X and Y independent plus one dependent variable. It is not possible to get the desired output from only that data.
You are getting cell numbers because you are only passing a single array to contour() and when you only pass a single array then it assumes that the x coordinates is 1 : number_of_columns and that the y coordinates are 1 : number_of_rows
It is.
data = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/736719/Abb73at42.xlsx')
data = 117×2 table
X Y _______ ______ -69.793 1.3879 -69.635 2.4547 -69.537 3.4459 -69.432 4.904 -69.352 6.4546 -69.334 7.5779 -69.161 9.0059 -68.937 10.381 -68.975 11.324 -68.975 12.41 -68.975 13.496 -68.889 14.557 -68.548 16.102 -68.435 17.943 -68.376 19.148 -68.172 20.606
dataArray = table2array(data);
figure
contourf(dataArray, 'ShowText','on')
Ax = gca;
xt = get(Ax, 'XTick');
xtlbl = compose('%.2f',linspace(min(data.X), max(data.X), numel(xt)));
set(Ax, 'XTickLabel',xtlbl)
Note — The x-tick values themselves are not changed, only the x-tick labels change. I am not certain that the same approach would work for the y-axis, since those are much more variable. The best I can do in that respect is to enable the text labels on the contours.
.
Thank you. It looks much better to my desired result.
As always, my pleasure!
.

Sign in to comment.

More Answers (0)

Categories

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!