How to achieve identical timing of two side by side annotations

조회 수: 1 (최근 30일)
Kara Presbrey
Kara Presbrey 2021년 4월 9일
댓글: Walter Roberson 2021년 4월 9일
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
Kara Presbrey
Kara Presbrey 2021년 4월 9일
Is the code above a case where multiple axes are affected?
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