Plot 2 Y axes using GUI and Handle structures
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I am using handle structures to create my figures and want two Y axes. When I create the second y axis it deletes the first. What I am trying to achieve is a histogram (left axis) and CDF (right axis) on the one plot.
What am I missing in my code? Thanks.
hs.A_PT_PnLPct = axes;
hs.A_PT_PnLPct.Parent = hs.Fig;
hs.A_PT_PnLPct.Title.String = 'Returns';
hs.A_PT_PnLPct.FontSize = 8;
hs.A_PT_PnLPct.Title.FontSize = 10;
hs.A_PT_PnLPct.XLabel.String = 'Return %';
hs.A_PT_PnLPct.YAxisLocation = 'Left';
hs.A_PT_PnLPct.YLabel.String = 'Frequency';
hs.A_PT_PnLPct.Units = 'pixels';
hs.A_PT_PnLPct.XGrid = 'on';
hs.A_PT_PnLPct.YGrid = 'on';
hold( hs.A_PT_PnLPct, 'on' );
hs.A_PT_PnLPct.YAxisLocation = 'Right';
hs.A_PT_PnLPct.YLabel.String = 'CDF';
hs.A_PT_PnLPct.Position = [990 430 300 300];
0 commentaires
Réponses (1)
Josh
le 28 Fév 2017
I think you might have to make two axes objects on top of each other. Plot your histogram on one and the CDF on the other.
% Create axes
a1 = axes; a2 = axes;
% Ensure that axes are overlayed:
a2.Position = a1.Position;
% Move second y-axis to the right:
a2.YAxisLocation='Right';
% Turn off second x-axs:
a2.XAxis.Visible='off';
% Set the second axis (the one on top) to have a clear background:
a2.Color='none';
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!