How can i make graph something like this?

1 回表示 (過去 30 日間)
Firman Pahrizal
Firman Pahrizal 2017 年 5 月 1 日
コメント済み: Firman Pahrizal 2017 年 5 月 5 日
i want to make graph something like this how i can do this. every dots have a different color based on mean on weighted value. what kind of function to make something like this? if anyone can provide me with different example i would appreciate it
regards,
fireman

採用された回答

Kevin Gleason
Kevin Gleason 2017 年 5 月 3 日
編集済み: Walter Roberson 2017 年 5 月 3 日
The bases of this graph is a scatter plot. You can provide a scatter plot with a colormap that supplys a color for each individual dot: https://www.mathworks.com/help/matlab/ref/scatter.html#btrli6o-1_1
x = linspace(0,3*pi,200);
y = cos(x) + rand(1,200);
c = linspace(1,10,length(x));
scatter(x,y,[],c, 'filled')
colorbar; % display color bar to right
In the case of the graph you mentioned, c is an M-by-3 matrix, which defines an RGB value for each dot based on mean weighted value. You will need to generate this M-by-3 matrix.
We can create a "jet" colormap, and index into it to choose a color based on the graphic above:
function c = MyColorBar(xData,yData)
spectrum = jet(10); % Generate 10 RGB values
data = xData+yData;
result = (data - min(data))./(max(data) - min(data)) .* 9; % normalize values to 0-9
indices = floor(result) + 1; % indices for each value 1-10
c = spectrum(indices,:); % return proper color values for each point
end
You can test the above code as follows:
y = rand(1,1000) .* 10;
x = rand(1,1000) .* 10;
c=MyColorBar(x,y);
scatter(x,y,25,c,'filled')
  1 件のコメント
Firman Pahrizal
Firman Pahrizal 2017 年 5 月 5 日
Thank you so much kevin and walter for your reply to this question. because i am not soo good at matlab and it helps me a lot. i will try my data and let see. if it works ,i will let you know. basically the dot is an 3d axis and each dot has a 2 data comparison between force and density. if the force and density correlated and the weighted mean will be around 1 so when i plotted should be like that.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDiscrete Data Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by