How do I plot a multivariate distribution?

2 ビュー (過去 30 日間)
Fabian Gock
Fabian Gock 2018 年 8 月 2 日
回答済み: Pawel Jastrzebski 2018 年 8 月 6 日
I have the efficiency map of an electric drive, in wich I plottet the operating points (torque at rpm) during a driving cycle.
Now I somehow want to display in wich areas the system is operating the most. So a multivariate distributional plot with peaks at the areas where the density of points is higher would be my wish.
Please find the attached file as an example (x-Axis is rpm, y-Axis is torque)
Thanks in advance -Fabian
  1 件のコメント
Fabian Gock
Fabian Gock 2018 年 8 月 2 日
編集済み: Fabian Gock 2018 年 8 月 6 日
Like this

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

採用された回答

Pawel Jastrzebski
Pawel Jastrzebski 2018 年 8 月 6 日
Consider the following example:
NoOfPoints = 1000;
% Generate 'x' and 'y'
x = rand(NoOfPoints,1);
y = rand(NoOfPoints,1);
% 2d plot of the data
hFig(1) = figure;
hAx(1) = gca();
p(1) = scatter(...
hAx(1),...
x,...
y,...
'ro');
grid on
% generate histogram of the data
% this will give you the density of the points
hFig(2) = figure;
hAx(2) = gca();
NoOfBins = 10;
p(2) = histogram2(hAx(2),...
x,...
y,...
NoOfBins);
% extract peak value of every bin as well as it's
% 'x' and 'y' location
BinCenterX = p(2).XBinEdges(1:end-1) + diff(p(2).XBinEdges)/2;
BinCenterY = p(2).YBinEdges(1:end-1) + diff(p(2).YBinEdges)/2;
BinPeaks = p(2).Values;
% plot values from histogram as surface plot
hFig(3) = figure;
hAx(3) = gca();
p(3) = surface(hAx(3),...
BinCenterX,...
BinCenterY,...
BinPeaks,...
'EdgeAlpha',0.3,...
'FaceAlpha',0.4);
hold on
p(3) = scatter3(...
hAx(3),...
x,...
y,...
zeros(size(x)),...
'ro');
colorbar;
view(3)
grid on;
% use interpolation function to make the surface
% plot smoother
[meshX, meshY] = meshgrid(linspace(0,1,50));
BinPeaksInterp = interp2(...
BinCenterX,...
BinCenterY,...
BinPeaks,...
meshX,meshY,...
'cubic');
hFig(4) = figure;
hAx(4) = gca();
p(4) = surface(hAx(4) ,...
meshX,...
meshY,...
BinPeaksInterp,...
'EdgeAlpha',0.3,...
'FaceAlpha',0.4);
hold on
p(5) = scatter3(hAx(4),...
x,...
y,...
zeros(size(x)),...
'ro');
colorbar;
view(3)
grid on;

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDescriptive Statistics and Visualization についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by