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 Kommentar

Flum
Flum am 9 Jul. 2016
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!

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 5 Jul. 2016

Kommentiert:

am 9 Jul. 2016

Community Treasure Hunt

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

Start Hunting!

Translated by