フィルターのクリア

How to remove specific colour from "surf" plot?

8 ビュー (過去 30 日間)
Mariana Melo
Mariana Melo 2019 年 11 月 28 日
コメント済み: Mariana Melo 2019 年 12 月 6 日
I am trying to generate a density plot overlayed on a background image.
For me it is interesting the points where the density is higher, so I want to remove the blue color, or make it transparent somehow.
This is how i generated this figure. I used "dscatter" function from Mathworks to generate density plot.
figure
img = imread('estimulo_neutro.jpg');
image('CData',img,'XData',[0 1080],'YData',[1900 0])
x = vector0(:,1);
y = vector0(:,2);
hold on
t = dscatter(x, y, 'plottype', 'surf');
colormap(jet)

採用された回答

Daniel M
Daniel M 2019 年 11 月 28 日
I don't have this dscatter function, but here is an example of how to do this with imagesc (which is similar enough that you could translate it to your situation). It involves setting the AlphaData property of your image. In the following example, I do so based on if the value is NaN. But you could do it for any value (and thus any colour).
clearvars
close all
clc
% get some data and plot it
z = peaks;
x = 1:size(z,1);
y = 1:size(z,2);
figure
imagesc(x,y,z);
colorbar
% now make some values in z NaN and plot them blank
nanz = z;
nanz(z < 1 & z > -1) = NaN;
figure
I = imagesc(x,y,nanz);
colorbar
% Use the AlphaData property to set the NaN values to blank
I.AlphaData = ones(size(nanz));
I.AlphaData(isnan(nanz)) = 0;
  1 件のコメント
Mariana Melo
Mariana Melo 2019 年 12 月 6 日
It worked perfectly.
Thank you!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by