フィルターのクリア

How can I color the area under a histfit curve?

5 ビュー (過去 30 日間)
Camilla Ancona
Camilla Ancona 2021 年 5 月 29 日
編集済み: DGM 2021 年 5 月 30 日
Hello everyone, I am trying to make in Matlab a plot called heated density plot in R that is basically a smoothed histogram whose area under the curve is colored accordingly to the belonging to a certain "bin". Can everyone help me doing this? I would really appreciate this. I attach an example of what the outcome should look like more or less. Thank you

採用された回答

Tala
Tala 2021 年 5 月 29 日
I assume you have an array that contains the envelope of your curve. If yes, this should help you! something like:
section1=1:0.1:2;
section2=2:0.1:3;
area(section1,yourarray);
hold all
area(section2,yourarray);
  1 件のコメント
Camilla Ancona
Camilla Ancona 2021 年 5 月 30 日
編集済み: Camilla Ancona 2021 年 5 月 30 日
Thank you for your answer! In truth I changed my mind and I am trying to visualize my data through a violin plot but i have the same issue to color the area of the violin or/and the datapoints color accordingly to their belonging of a certain class. here there is my attempt
I'm trying to visualize my data by means of this package, but I was wondering if there is a way to color differently the datapoints accordingly to their belonging of a certain range of equivalently the area of the violin. this is my attemot in substituiting the CData matrix with arranged RGB triplets but this approach does not works
vs = violinplot(data,[],'Width',0.2,'Bandwidth',0.3,'ViolinColor',[0 0 1],'ViolinAlpha',0.5,'EdgeColor',[0 0 1],'BoxColor',[0 0 0],'MedianColor',[1 0 0]);
hold on
h = vs(1).ScatterPlot;
cdata = vs.ScatterPlot.CData;
c = repmat(cdata,[1446 1]);
c(1:freq_new_net(1),:) = repmat([1 0 0],[freq_new_net(1) 1]);
c(freq_new_net(1)+1:freq_new_net(1)+freq_new_net(2),:) = repmat([1 1 0],[freq_new_net(2) 1]);
c(freq_new_net(1)+freq_new_net(2)+1:freq_new_net(1)+freq_new_net(2)+freq_new_net(3),:) = repmat([1 1 1],[freq_new_net(3) 1]);
c(freq_new_net(1)+freq_new_net(2)+freq_new_net(3)+1:freq_new_net(1)+ freq_new_net(2)+freq_new_net(3)+freq_new_net(4),:) = repmat([0 0 1],[freq_new_net(4) 1]);
c(freq_new_net(1)+freq_new_net(2)+freq_new_net(3)+freq_new_net(4)+1:1446,:) = repmat([0 1 0],[freq_new_net(5) 1]);
h.CData = c;
vs.ScatterPlot.CData = c;

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

その他の回答 (1 件)

DGM
DGM 2021 年 5 月 30 日
編集済み: DGM 2021 年 5 月 30 日
I have no familiarity with violin plots or your data, and I don't know which violin plot tools you chose to use. If you're trying to essentially control the resolution of your colormap, consider a simplified example:
x = 1:100;
y = 1:100;
nbins = 5;
% find which bin each point belongs in
[~,~,idx] = histcounts(y,nbins);
% start with a reduced colormap
cmap = jet(nbins);
% combine to get cdata
scatter(x,y,[],cmap(idx,:))
I don't know if that's helpful in your case.

カテゴリ

Help Center および File ExchangeData Distribution Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by