Hello there,
I have another problem… I want to place annotations in my plot, see the figure below.
Now, as one can see the x-axis uses datenum-numbers. How can I position the annotations using these coordinates? Each of the vertical lines should be placed at 00:00 (12PM), the dates in the center of the resulting box.
This is how far I got:
clc clear all close all % Get the data
filepath=''; % Note: Im realen File gibt es natürlich einen Pfad
fprintf('Path: %s\n', filepath) fprintf('\nLoad totaldev ...\n') totaldev = xlsread(strcat(filepath,'totaldev.xlsx')); fprintf(' ...done!\nLoad plant_load ...') plant_load = xlsread(strcat(filepath,'load.xlsx')); fprintf(' ...done!\n') data=[plant_load(:,1),plant_load(:,2),totaldev(:,2)]; data(:,1)=x2mdate(data(:,1)); fprintf('Prepare data ...\n') % Remove values below 0 and above 100 (plant load is 0% to 100%
data(any(data(:,2)<0,2),:)=[]; data(any(data(:,2)>100,2),:)=[]; % Remove values below -100 and above 100 (error can't be more than +-100%)
data(any(data(:,3)<-100,2),:)=[]; data(any(data(:,3)>100,2),:)=[]; % Compute average of time series
% Sample rate is 2sec, so 30 values cover a minute
data_avg=[data(:,1), movavg(data(:,2),30,30), movavg(data(:,3),30,30)]; data_avg(1:30,2)=data(1:30,2); data_avg(1:30,3)=data(1:30,3); fprintf(' ...done!\n') fprintf('\nCreate plot') % Plot 'em
plot(data_avg(:,1),data_avg(:,2),data(:,1),data_avg(:,3)) NumTicks = 20; L = get(gca,'XLim'); set(gca,'XTick',linspace(L(1),L(2),NumTicks)) datetick('x','HH:MM','keepticks','keeplimits');
The function movavg will be replaced by tomorrow. The data is as follows (example) ([Time; Data1; Data2]):
735728,605428241 80,6717800000000 11,6650710000000 735728,605451389 80,6717800000000 9,12566720000000 735728,605474537 80,1416200000000 9,24074830000000 735728,605497685 80,1416200000000 9,20919460000000 735728,605520833 80,1416200000000 9,47081590000000 735728,605543982 80,3848000000000 9,28115980000000 735728,605567130 80,3848000000000 8,55264740000000 735728,605590278 80,3848000000000 9,47107710000000 735728,605613426 80,5608400000000 9,42203640000000 735728,605636574 80,6196400000000 9,32575490000000 735728,605659722 80,6196400000000 9,25049830000000 735728,605682870 80,6998100000000 9,48914560000000 735728,605706019 80,6998100000000 9,52505890000000 735728,605729167 80,6998100000000 9,12462120000000 735728,605752315 80,1338500000000 8,44201380000000 735728,605775463 80,1338500000000 8,38791130000000 735728,605798611 79,9584800000000 8,67874090000000 735728,605821759 79,9584800000000 8,92738190000000 735728,605844908 79,5133300000000 9,50254300000000
I have no idea now how to place the annotations using the code. Since I have to plot this figure a few times I don't want to set the annotations by hand each time …
I hope someone can help =)
Cheers from Germany
Best Answer