Specific color corresponding to specific data using contourf colormap

8次意见(过去30天)
S CH.
S CH. 2021年5月12日
编辑: S CH.on 25 Jun 2021
你好,
I would like to know if we can give a specific color to a specific data and plot them on Matlab ?
For example, I have a 3000x3000 matrix with x and y axis, I need to plot a range of data in a specific color.
我已经生成了地图,但颜色是随机的
this is my code :
a =数据;
数字;
[v,x] = meshgrid(v,x);
contourf(v,x,a)
数字;
%Colourgb = HSV(喷气机);
c = Colormap(喷气机);%jet
L = [0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1];
[cdd hc]=contourf(v,x,A,[-0.01 L]);
Recolor_contourf(hc,c,L,'vert');
I want for example if A(x,y)==0.07 the colormap will be green ...
I can give more details.
Kind regards,
S.C.
6评论
S CH.
S CH. on 17 May 2021
你好,
谢谢你的所有答案,我会稍后检查一下,我用截止日期转换为另一个项目,
The best thing to confirm your response is to try them, so I don't want to accept, give me a moment, please.
再次感谢。

Sign in to comment.

答案(2)


S CH.
S CH. on 25 Jun 2021
编辑:S CH. on 25 Jun 2021
你好,
谢谢 @DGM. , @J. Alex Lee @Chad Greene. for your answers! It was great to use these methods and it is what I need!
I used the contourfcmap and I directly chose the number of levels I want, unfortunately I'm struggling to do a loop of 100 images using this method ! anyone can help me please?
To explain the problem, I have 100 matrices in a folder (each matrix is an image that I want to contourfmap) and after that save them in a folder as images with the colors I chose in contourfmap. Is this possible ?
这是我的代码:
fori = 1:N
%names is the char name of all matrices
如果i < 10
名称(i,:) = strcat("X_t0000",字符串(i),“。垫”);
别的
名称(i,:) = strcat(“x_t000”,字符串(i),“。垫”);
end
%a = eval(名称);%(i,:));
百分比后,我不知道如何使用名称,以便如下更改:
数据=加载(f(i).name);
z = data.data;%iside each matrix there is matrix named 'data'
h1 = contourfcmap(v,x,z,[0.1 0.33],jet(1),[.1 .1 .1], [.9 .9 .9],'eastoutside')
d = h1.c.
l=h1.h
export_fig(fullfile(文件夹,sprintf('%05d.png', i)))
%%% Here I had only one image appeared I think the last one.
%iMwrite(d,fullfile(文件夹,sprintf('%05d.png',i)))))))
%a = cat(3,名称);在这里我想将100个矩阵连接到
%一个像2048x2048x100,但我没有成功
end
If it isn't clear please tell me to explain more. Thank you in advance.
S.C.

社区宝藏狩猎

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

开始狩猎!