I'm trying to plot matrix data from an Excel file, but the plot I obtained (named "2") doesn't match my expected result (named "1"); here's my code—can anyone assist?
Show older comments
I am trying to plot my matrix data from an excel file. However, what I obtained is the same as what I desired. The expected plot is name 1, while what I have obtained is named 2. Here is my code:
% Load the matrix from the Excel sheet
matrix1 = readmatrix('Sample_Axes.xlsx', 'Sheet', 'one');
% Create a figure with subplots
figure;
% Plot matrix1 using contour
subplot(1, 3, 1);
contourf(matrix1, 20, 'LineColor', 'none'); % 20 contour levels, 'LineColor', 'none' for no contour lines
cb1 = colorbar;
colormap jet;
title('Matrix 1');
Can someone help me out?
8 Comments
m=readmatrix('Sample_Axes.xlsx');
subplot(1,3,1)
contourf(m, 20, 'LineColor', 'none');
colormap(jet)
subplot(1,3,2)
contourf(m, 50, 'LineColor', 'none');
colormap(jet)
subplot(1,3,3)
contourf(m, 100, 'LineColor', 'none');
colormap(jet)
figure
contourf(flipud(m), 100, 'LineColor', 'none');
colormap(jet)
[min(m(:)) max(m(:))]
Your data simply doesn't appear to have such a range as the alternate...adding more levels shows a little more structure, but the range is not nearly as wide as in the other image.
Attach the other data file so folks can compare.
Oluwasogo
on 24 Aug 2024
dpb
on 24 Aug 2024
Some sort of transformation has been done on the image, then. Note the last figure I added to the above; if you invert the image up/down, then you can see that it does compare to the alternate image you posted. But, note also the scale of the colorbar() there is logarithmic but the image data of your array are both positive and negative so a simple log transform won't suffice as can't log() a negative value.
From whence then, did the other image come?
Mathieu NOE
on 26 Aug 2024
you probably need a kind of log scaled colorbar as in your provided picture
Oluwasogo
on 26 Aug 2024
dpb
on 26 Aug 2024
"...need a kind of log scaled colorbar"
Just changing the scale of the colorbar won't change the appearance of the image; not to mention the above point that the data are both positive and negative, so log(<0) --> complex which can't then plot.
There has had to been a transformation of some sort first to get that plot from the original dataset.
this is the posted reference image
imshow('pict.png')
- we can clearly see the colorbar having a kind of log (signed) scale (can be interpreted as a "transformation" if you prefer) - to emphasize the rendering of low amplitude details around zero , which is the exact same topic addressed in the link I provided above (symmetric (diverging) logarithmic color map/scale)
Oluwasogo
on 28 Aug 2024
Answers (0)
Categories
Find more on Color and Styling in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

