필터 지우기
필터 지우기

How can I make an inset plot with log axes?

조회 수: 8 (최근 30일)
Mark
Mark 2014년 5월 5일
편집: Cedric 2014년 5월 5일
Hello,
I'm trying to make plots that have insets. I would like for either the main plot, or the inset plot to have log axes.
For some reason, semilogy doesn't seem to work properly with the inset package.
Thoughts?
Mark

채택된 답변

Cedric
Cedric 2014년 5월 5일
편집: Cedric 2014년 5월 5일
You could build the insert by yourself. Here is an example:
% - Define dummy data.
t = 0 : 0.1 : 10 ;
yModel = sin( t ) .* exp( -0.2*t ) ;
yData = yModel - 0.5 + rand( size( yModel )) ;
% - Create/init figure.
figure(1) ; clf ; hold on ; grid on ;
set( gcf, 'Color', 'White' ) ;
% - Build main plot/axes.
plot( t, yModel, 'b' )
plot( t, yData, 'rx', 'MarkerSize', 5, 'LineWidth', 2 ) ;
ylim( [min(yData), 1.8*max(yData)] ) ; % Create space for insert on top.
xlabel( '\theta [rad]' ) ;
% - Build new insert axes + plot.
axes( 'Position', [0.6,0.65,0.3,0.25] ) ;
yDiff = yData - yModel ;
plot( [t; t], [zeros(size(t)); yDiff], 'm.-', 'MarkerSize', 5 ) ;
  댓글 수: 2
Mark
Mark 2014년 5월 5일
That works very well, thanks a lot!
Mark
Cedric
Cedric 2014년 5월 5일
편집: Cedric 2014년 5월 5일
You're welcome.
Note that you can change the X and Y scales of either axes, by running e.g.
set( gca, 'YScale', 'Log' ) ;
Actually, evaluate the following commands in the command line and see their outputs, and you'll understand how it works:
set( gcf )
set( gca )
set( gca, 'YScale' )

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Two y-axis에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by