How can I label two axys in the same plot?
5 ビュー (過去 30 日間)
表示 古いコメント
Hello everybody. I have a plot with 2 x-axys and 2 y-axys. I want to put a label for the x-axys on the bottom of the graph and another label on the top of the graph under the title of the graph.
Finally I want to put a label for two y-axys, one label on the left of the graph and another label on the right of the graph.
I hope I have been most clear as possible. Thanks
Gianmarco
0 件のコメント
回答 (1 件)
Sonam Gupta
2017 年 12 月 8 日
You can do this as follows:
x1 = 1:10;
y1 = 1:2:20;
y2 = x1;
x2 = y1;
close all;
figure (9)
ax1 = gca;
hl1 = line(x1,y1,'Color','r');
set(ax1,'XColor','r','YColor','r')
ylabel(ax1,'y-axis-left')
xlabel(ax1,'x-axis-bottom')
ax2 = axes('Position',get(ax1,'Position'),'XAxisLocation','top',...
'YAxisLocation','right','Color','none','XColor','k','YColor','k');
hl2 = line(x2,y2,'Color','k','Parent',ax2);
ylabel(ax2,' (y-axes-right)')
xlabel(ax2,'x-axis-top')
0 件のコメント
参考
カテゴリ
Find more on Axis Labels in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!