How can apply scatter or plot functions with two xx and yy axis?
3 ビュー (過去 30 日間)
古いコメントを表示
Riyadh Muttaleb
2019 年 1 月 21 日
コメント済み: Riyadh Muttaleb
2019 年 1 月 22 日
Hi Everyone,
I am try to use the code below that I got it from : https://www.mathworks.com/help/matlab/creating_plots/graph-with-multiple-x-axes-and-y-axes.html
to apply it with plot OR scatter fuctions but it does't work!
I have histogram in the first plot and Scatter OR plot in the socond.
Thanks in advance
Riyadh
figure
x1 = 0:0.1:40;
y1 = 4.*cos(x1)./(x1+2);
line(x1,y1,'Color','r')
ax1 = gca; % current axes
ax1.XColor = 'r';
ax1.YColor = 'r';
ax1_pos = ax1.Position; % position of first axes
ax2 = axes('Position',ax1_pos,...
'XAxisLocation','top',...
'YAxisLocation','right',...
'Color','none');
x2 = 1:0.2:20;
y2 = x2.^2./x2.^3;
line(x2,y2,'Parent',ax2,'Color','k')
0 件のコメント
採用された回答
Arvind Sathyanarayanan
2019 年 1 月 21 日
Riyadh,
3 件のコメント
Arvind Sathyanarayanan
2019 年 1 月 22 日
Ah, I see what you mean! It looks like you need to set the properties after you use the plot command
close all;
figure;
line(1:10,1:10);
ax1 = gca; % current axes
ax1.XColor = 'r';
ax1.YColor = 'r';
ax1_pos = ax1.Position; % position of first axes
ax2 = axes('XAxisLocation','top',...
'YAxisLocation','right',...
'Color','none');
x=0:0.001:2*pi;
y=sin(x);
plot(x,y,'Parent',ax2,'Color','k');
ax2.XAxisLocation = 'top';
ax2.YAxisLocation = 'right';
ax2.Color = 'none'
Using the above code i got the following result. Please let me know if this works for you
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Animation についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!