How can I label two axys in the same plot?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (1)
Sonam Gupta
le 8 Déc 2017
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 commentaires
Voir également
Catégories
En savoir plus sur Line Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!