Plotting Grayscale from .csv with colorbar restriction

조회 수: 1 (최근 30일)
Jaslyn Tan
Jaslyn Tan 2019년 10월 24일
답변: Jaslyn Tan 2019년 11월 12일
Hi there,
Can anyone please help..? I have grayscale image data in a .csv file I need to plot. The values in the .csv are the z values that I wish to plot as an image, the x and y coordinates of the z values in the file represent the location of that pixel in the image.
I need to restrict the colorbar to say 0 to 0.5 to see the detail in the certain part of the image. Everything below 0 can be black, above 0.5 can be white, but I need 0-0.5 to be greyscale.
I have plotted using the following code but what I get is a mostly blank image.
Please can someone help? I attach the data and my plot.
filename = 'C:\\my data.csv';
M = csvread(filename)
J = contourf(M)
colormap gray
h = colorbar;
set(h, 'ylim', [0 0.5])

채택된 답변

Jaslyn Tan
Jaslyn Tan 2019년 11월 12일
In the end I used this:
filename = 'C:\\my data.csv';
M = csvread(filename)
clims = [0 1];
J = imagesc(M,clims)
colormap('jet')
Thank you so much for your help!

추가 답변 (1개)

Walter Roberson
Walter Roberson 2019년 10월 24일
  댓글 수: 1
Jaslyn Tan
Jaslyn Tan 2019년 10월 27일
Thank you so much! But
filename = 'C:\\my data.csv';
M = csvread(filename)
J = contourf(M)
colormap gray
caxis([0 0.5])
only changes the scale bar, the image is still all black. Am I doing this wrong..? Thank you in advance.

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

카테고리

Help CenterFile Exchange에서 Color and Styling에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by