How to achieve identical timing of two side by side annotations

1 vue (au cours des 30 derniers jours)
Kara Presbrey
Kara Presbrey le 9 Avr 2021
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;

Réponses (2)

Fangjun Jiang
Fangjun Jiang le 9 Avr 2021
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 commentaires
Kara Presbrey
Kara Presbrey le 9 Avr 2021
Is the code above a case where multiple axes are affected?
Walter Roberson
Walter Roberson le 9 Avr 2021
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.

Connectez-vous pour commenter.


Walter Roberson
Walter Roberson le 9 Avr 2021
For anything like this you should probably be using the third party Psychtoolbox http://psychtoolbox.org/
  2 commentaires
Kara Presbrey
Kara Presbrey le 9 Avr 2021
indeed. Unfortunately, the entire task is coded not with psychtoolbox already
Walter Roberson
Walter Roberson le 9 Avr 2021
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?

Connectez-vous pour commenter.

Catégories

En savoir plus sur Timing and presenting 2D and 3D stimuli dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by