필터 지우기
필터 지우기

Plot 2 Y axes using GUI and Handle structures

조회 수: 4 (최근 30일)
rb250660
rb250660 2017년 2월 28일
답변: Josh 2017년 2월 28일
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];

답변 (1개)

Josh
Josh 2017년 2월 28일
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';

카테고리

Help CenterFile Exchange에서 Histograms에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by