3 dataset plot in single dimension plane
2 ビュー (過去 30 日間)
古いコメントを表示
Hello there,
I have facing a problem while plotting a data set.
I have three variables,
a,b and c.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/963400/image.png)
I am trying to plot c with respect to a and b.
could you please figure out this situation.
0 件のコメント
回答 (2 件)
Riccardo Scorretti
2022 年 4 月 13 日
Hi Suraj, you can use mesh, surf, contour and many others functions (see https://fr.mathworks.com/help/matlab/visualize/representing-a-matrix-as-a-surface.html). For instance:
[x, y] = meshgrid(0:0.05:pi, 0:0.05:1);
c = exp(-2*y).*sin(-x);
figure
surf(x, y, c);
xlabel('x') ; ylabel('y') ; zlabel('c');
5 件のコメント
Riccardo Scorretti
2022 年 4 月 14 日
編集済み: Riccardo Scorretti
2022 年 4 月 14 日
It is still unclear to me (sorry).
Method #1: you could plot a and b as a function of c, instead of c as a function of a and b:
c = [0.001 0.002 0.003 0.00021 0.0025];
a = [65 45 35 55 33];
b = [80 114 85 90 95];
[~, ind] = sort(c);
figure
yyaxis left
plot(c(ind), a(ind), 'o-') ; xlabel('c') ; ylabel('a');
yyaxis right
plot(c(ind), b(ind), 's-') ; ylabel('b');
The information is the same, but I guess it is not what you want.
Riccardo Scorretti
2022 年 4 月 14 日
編集済み: Riccardo Scorretti
2022 年 4 月 14 日
Method #2: use circles of different size to represent the value of c. I hope at least it will inspire you.
c = [0.001 0.002 0.003 0.00021 0.0025];
a = [65 45 35 55 33];
b = [80 114 85 90 95];
% This parameter controls the average size of circles (just for aestetic purpose)
% I'm afraid it has to be adjusted manually depending on the number of
% points to plot and on the orders of magnitude of a and b
fact = 0.1;
figure
sz = fact*max(abs([a(:) ; b(:)])) / max(abs(c(:))); % = characteristic size to draw circles
sz_b = 0.01*max(abs(b));
t_ = linspace(0, 2*pi, 256);
assert(numel(a) == numel(b) && numel(a) == numel(c), 'a, b, and c must have the same number of elements');
for n = 1 : numel(c)
patch(a(n)+sz*c(n)*cos(t_), b(n)+sz*c(n)*sin(t_), 'r', ...
'EdgeColor', 'k', 'FaceAlpha', 0.4);
hold on
text(a(n), b(n)+sz*c(n)+sz_b, num2str(c(n)));
end
axis square ; box on ; grid on
xlabel('a') ; ylabel('b');
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!