Issue Plotting Array in Imagesc

I am trying to plot an array as an imagesc plot. The array is full of non-zero numbers, but imagesc plots them as zero. I think the issue is with scaling, but I don't know how to fix it. Screenshots attached to show what I mean. How do I scale my imagesc plot so that the numbers in the array are visible appropriately? Tried looking it up on the documentation but couldn't find a clear answer for my problem.

댓글 수: 3

Dyuman Joshi
Dyuman Joshi 2024년 3월 5일
편집: Dyuman Joshi 2024년 3월 5일
Try taking the log() of the absolute values of the data and see what the result is.
I suspect as most of the data (as seen in the image attached above), is around ~10^10, which is 0.001x10^13, thus the data looks closer to the 0.5x10^13 than to the max value.
If the problem still persists, please attach the data file using the paperclip button.
DGM
DGM 2024년 3월 5일
It might be worth looking at a histogram of the data to see if it would be prudent to pick colorscale limits other than the data extrema.
Mathieu NOE
Mathieu NOE 2024년 3월 5일
hello @Rose
it would help if you could share your data (and code if you have one)

댓글을 달려면 로그인하십시오.

답변 (1개)

Jatin
Jatin 2024년 8월 7일

0 개 추천

Hi,
This happens when “imagesc” automatically tries to scale the colormap based on the range of data in array. It makes it harder to visualise large range data using colormap if there are few outliers.
Few things that you might want to try are:
  1. Remove outliers from the data, this will make the visualisation of data better using automatic colormap scaling.
  2. Manually set the colormap limits using the “clim” property of the “imagesc” function, which allows you to define the range of data values that map to the colours.
For e.g.,
data = rand(10, 10) * 100;
% Create the imagesc plot
figure;
imagesc(data);
colorbar;
% Set the colour limits to the min and max of the data
clim([min(data(:)), max(data(:))]);
Kindly refer to “clim” documentation using link mentioned below:https://www.mathworks.com/help/releases/R2023b/matlab/ref/clim.html

댓글 수: 2

Your example does the opposite of what your text describes. Using imagesc() already sets CDataMapping to 'scaled' and sets clim to the data extrema by default.
As you say, you either need to remove outliers, or simply pick different limits for clim().
% a bunch of data close to zero, but with very wide tails
A = 1E6./randn(1000);
histogram(A)
% default scaling
imagesc(A)
% pick better limits
pct = 10;
newrange = prctile(A,[pct 100-pct],'all');
imagesc(A)
clim(newrange)
Jatin
Jatin 2024년 8월 8일
Hi @DGM, I stated the example just to show how "clim" can be used, but you are right I could have used a better limit. Thanks for your informative example.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Orange에 대해 자세히 알아보기

제품

릴리스

R2023b

태그

질문:

2024년 3월 5일

댓글:

2024년 8월 8일

Community Treasure Hunt

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

Start Hunting!

Translated by