# How can I label two axys in the same plot?

2 ビュー (過去 30 日間)
Gianmarco Polizia 2017 年 12 月 5 日

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

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

### 回答 (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')

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

### カテゴリ

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

### Community Treasure Hunt

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

Start Hunting!

Translated by