define color range in scatter plot
48 ビュー (過去 30 日間)
古いコメントを表示
Hi,
I have values ranging from 0 to 3000. Here, only for the values ranging between 2000 to 3000 I have to use the color palette, for rest of the values (i.e. 0 to 1000) the color should be in black..
And I am using scatter plot here.. Is it possible to define above conditions in the scatter plot..
0 件のコメント
採用された回答
Jonas
2022 年 6 月 29 日
編集済み: Jonas
2022 年 6 月 29 日
i do not fully understand, you want to use the pallett for split to 0 to 3000, but at a certain threshold you want to use black instead?
what about values between 1000 and 2000?
x = linspace(0,3*pi,2000);
y = cos(x) + rand(1,2000);
c = linspace(1,10,length(x));
sp=scatter(x,y,[],c);
currMap=colormap();
[~,highestCDataIdx]=max(sp.CData(sp.XData<=3));
highestCDataIdx=ceil(highestCDataIdx*size(currMap,1)/numel(sp.XData)); % scale CData Index by ration of colormap elements to number of XData to map
currMap(1:highestCDataIdx,:)=0;
colormap(currMap)
you can also change values inbetween without changing the pallett
x = linspace(0,3*pi,2000);
y = cos(x) + rand(1,2000);
c = linspace(1,10,length(x));
sp=scatter(x,y,[],c);
currMap=colormap();
[~,highestCDataIdx]=max(sp.CData(sp.XData<=3));
highestCDataIdx=ceil(highestCDataIdx*size(currMap,1)/numel(sp.XData)); % scale CData Index by ration of colormap elements to number of XData to map
currMap(1:highestCDataIdx,:)=0;
colormap(currMap);
delInbetween=sp.XData<5 & sp.XData>4;
sp.XData(delInbetween)=[];
sp.YData(delInbetween)=[];
sp.CData(delInbetween)=[];
12 件のコメント
Jonas
2022 年 7 月 1 日
so some things to make the points in your cloud better distinctable: you can change the marker and the marker size and the coarseness of you colormap:
load('matlab.mat','x','y')
scatter(x,y,[],linspace(0,1,numel(x)),'.','SizeData',1)
colorbar;
cm=colormap('colorcube');
cm=cm(1:8:end,:);
colormap(cm)
or, if you want to use the supplied c for whatever reason
load('matlab.mat','c');
figure;
scatter(x,y,[],c,'.','SizeData',1)
colorbar;
cm=colormap('colorcube');
cm=cm(1:8:end,:);
colormap(cm)
その他の回答 (1 件)
参考
カテゴリ
Help Center および File Exchange で Colormaps についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!