Placing transparent rectangles on top of a plot
Show older comments
Hey all,
I am trying to place several rectanges over a plot (wavelet coherence) but am struggling to do so.
I have been using the following code below, which has been creating the plots successfully but the rectangles do not seem to appear on the plots.
I would be so grateful for a helping hand! :)
Please let me know if there's anymore/example data I can provide.
wcoherence(data1,data2);
ax = gca;
final_onset = dataTable.onsetsWC(end);
final_duration = dataTable.durationsWC(end);
max_x_limit = final_onset + final_duration;
xlim([0, max_x_limit]);
for i = 1:height(dataTable)
onset = dataTable.onsetsWC(i);
duration = dataTable.durationsWC(i);
trialType = dataTable.Trialtype(i);
if strcmp(trialType, 'Chase')
barColor = [1, 0, 0, 1];
elseif strcmp(trialType, 'Follow')
barColor = [0, 1, 0, 1];
end
rectangle(ax, 'Position', [onset, 0, duration, 1], 'FaceColor', barColor, 'EdgeColor', 'none');
end
figure_title = sprintf('Dyad-%d-Channel-%d', p, j);
set(gcf, 'Name', figure_title);
save_path = 'C:\Users\emre.yavuz\Desktop\DataGLM\Waveletcoherence';
save_name = sprintf('Dyad_%d_Channel_%d.fig', p, j);
saveas(gcf, fullfile(save_path, save_name));
Accepted Answer
More Answers (0)
Categories
Find more on Line Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
