Hi, I made a plot by using a tutorial found on youtube (see figure)
I need to add a vertical line.
This is the code:
h = findobj('type','figure');n = length(h);dataToPlot = mediaInfraCondRev;plotHeatMap
The last line (plotHeatMap) opens this code:
f = figure(n+1); %Inizialize plotting vectors
buf_len = 1895; % about 30 seconds of data
%index = 1:buf_len; % riga originale trovata su internet
index = time.minsTot(:,1)'; % riga modificata per plottare minuti su asse x
zeroIndex = zeros(size(index)); tcdata = zeroIndex; % rolling vector of temperature readings length buf_len
limits = [min(dataToPlot) max(dataToPlot+0.05)]; %expected range of temps for plotting and color scaling
%set the axes limits and select a 2D (x,z) view (this prevents
%autoscaling
% myAxes = axes ('xLim', [0 buf_len], 'YLim', [0 0.1], 'Zlim', limits,
% 'CLim', limits); % questa e' la riga originale trovata su youtube
myAxes = axes ('xLim', [0 max(index)], 'YLim', [0 0.1], 'Zlim', limits, 'CLim', limits); % questa e' la riga modificata per plottare i minuti su asse x
view(0,0); grid on; % Create surface graphics object s to display temperature data in (x,z)
% plane, area color based on temperature readings
% X e Y definiscono le coordinate sul rettangolo. Z definisce la
% superficie sulla griglia e la colora in base a C
% 'XData' 'YData' 'ZData' 'CData'
s = surface (index, [0, 0], [tcdata; zeroIndex], [tcdata; tcdata]); % Set surface face and edges to fill with CData values, add labels
set(s, 'EdgeColor', 'flat', 'FaceColor', 'flat', 'Parent', myAxes) % parent 'myAxes' dice di mettere il surface object all'interno degli assi
colorbar title('Temperature Readings, \circC') xlabel('Time (minutes)') zlabel('Temperature(\circC)') set(f, 'Position', [200 200 890 660]) drawnow; % INSERIAMO I DATI
tcdata = dataToPlot'; %update plot data and corresponding color
set(s, 'Zdata', [tcdata; zeroIndex], 'Cdata', [tcdata; tcdata]) %force MATLAB to redraw the figure
drawnow;
Everything looks perfect, except for one thing: I need to add a vertical line on minute 3 and minute 23. I tried with:
line([3 3], get(gca, 'ylim'));
This line kind of works on a normal plot (see example)
But it does not show anything if I try on this plot and I can't figure out what to do. Any suggestion?
Thank you for your time, Gluce
Best Answer