How to achieve identical timing of two side by side annotations

1 次查看(过去 30 天)
I have a figure that is just a full-screen white box. On this figure, I want to draw a green cross in the center, and a colored rectangle at the same height but at the left edge of the screen. It's very important that these two annotations appear at the exact same time for a research project.
This is what I am currently doing, but I don't really know for sure how it works and am worried that the cross annotation might be drawn before the rectangle is drawn:
annotation('textbox',[0,0,1,1],'String','+',...
'FontName','Arial','FontSize',108,...
'Color',cross_color,...
'EdgeColor','none',...
'HorizontalAlignment','center','VerticalAlignment','middle');
annotation('rectangle',[0,0.45,0.05625,0.1],'Color','k','FaceColor','k');
drawnow;

回答(2 个)

Fangjun Jiang
Fangjun Jiang 2021-4-9
What you can do is this. I think it can improve the timing.
h1=annotation(..., 'visible','off'):
h2=annotation(..., 'visible','off');
set([h1,h2],'visible','on')
  3 个评论
Walter Roberson
Walter Roberson 2021-4-9
Tricky. Annotations are not made to the current axes. Annotations are drawn into a pane that is logically "in front" of all other items, using figure coordinates (not data coordinates!). The first annotation() for the figure could potentially involve creation of an annotation pane.
Hmmm... looks like perhaps these days annotations are potentially in uipanel() or uitab() rather than in figures directly, so there could be multiple such objects per figure, so it would make even more sense for the first annotation() call in the container to need to build the annotation pane.
Which suggests that potentially if you did
h0 = annotation(something, 'visible', 'off'); %force annotation pane to be built
drawnow()
%now draw the two useful annotations. In theory should not need 'visible',
%'off' for this.
then you just might get more consistent timing.

请先登录,再进行评论。


Walter Roberson
Walter Roberson 2021-4-9
For anything like this you should probably be using the third party Psychtoolbox http://psychtoolbox.org/
  2 个评论
Kara Presbrey
Kara Presbrey 2021-4-9
indeed. Unfortunately, the entire task is coded not with psychtoolbox already
Walter Roberson
Walter Roberson 2021-4-9
Could you use Computer Vision Toolbox insertText() and insertShape() to draw into an array, then image() the array so that everything becomes visible at the same time?

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Timing and presenting 2D and 3D stimuli 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by