Scale axis (pixel : represented unit)

Hello everybody!
Could anyone help me with axis scaling? I have several data series each for a different time frame, and would like to plot each in a separate figure. For better comparison, it would be nice if they all had the same time scaling (e.g. 100 pixels represent one month).
What I have tried so far looks roughly like that:
% First plot:
figure(1)
plot(time1,data1)
% set axis limits:
x1 = [time1(1) time1(end)];
xlim(x1)
datetick('keeplimits')
% set size of graph:
% pos_h is position_horizontal
% pos_v is position_vertical
set(gcf,'position',[pos_h,pos_v,width*x1/x1,hight])
% Second plot:
figure(2)
plot(time2,data2)
% set axis limits:
x2 = [time2(1) time2(end)];
xlim(x2)
datetick('keeplimits')
% set size of graph:
% pos_h is position_horizontal
% pos_v is position_vertical
set(gcf,'position',[pos_h, pos_v, width*x2/x1, hight])
However, this does not work properly. I guess it is because of the title, axis labels, ticks etc. which are also space consuming and not included in a simple calculation like "x2/x1". The same problem occurs with
fig = figure()
set(fig,'Position',[...]);
I'd appreciate all help and also useful links (as there surely must be solution somewhere - just that I could not find it)!

댓글 수: 1

Flum
Flum 2016년 7월 9일
The reason why the code above does not work is that the 'Position'-Property on gcf controls the size of the whole figure (including all ornamentation elements such as title, outer legends etc.). However, it can be done by attributing 'Position' to gca, which directly controls the appearance of the axes. After having replaced gcf by gca, the code works fine for this problem!

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

답변 (0개)

카테고리

도움말 센터File Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

질문:

2016년 7월 5일

댓글:

2016년 7월 9일

Community Treasure Hunt

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

Start Hunting!

Translated by