Plot 2 Y axes using GUI and Handle structures

2 Ansichten (letzte 30 Tage)
N/A
N/A am 28 Feb. 2017
Beantwortet: Josh am 28 Feb. 2017
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];

Antworten (1)

Josh
Josh am 28 Feb. 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';

Kategorien

Mehr zu Line Plots finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by