How can I label two axys in the same plot?
1 次查看(过去 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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Line Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!