Error making coherence plots

I am wondering what this message means. I have read the neurospec20 document for type 2 analysis, but even after reading that, can't seem to figure out where I'm going wrong with my plots. I am trying to create EMG coherence plots using type 2 analysis. This is my script (which is modeled off of the neurospec20_demos script):
freq=75;
lag_tot=200;
lag_neg=100;
psp2_tf(f,t,cl,freq,lag_tot,lag_neg)
and this is my error:
Error using axes
Axes cannot be a child of ColorBar.
Error in psptf_ch1 (line 142)
axes(H)
Error in psp2_tf (line 77)
psptf_ch1(f,cl,freq,t_inc,n_contour,colorbar_flag,line_flag)
Any advice at all would be much appreciated.

 Risposta accettata

I had a look at the code, and it is broken for R2014b or later.
The code is doing
H=colorbar;
v=get(H);
axes(H)
for sect_ind=1:n_seg
ch_c95_vector=[v.XLim;cl(sect_ind).ch_c95,cl(sect_ind).ch_c95];
line(ch_c95_vector(1,:),ch_c95_vector(2,:),'Color','k')
end
In R2014a and before, colorbar() created an axes() object and drew a simple image into it. Because it was an axes, it was possible to grab the axes and plot into it, such as to create 95% confidence lines in the color bar.
In R2014b and newer, colorbar() creates Colorbar objects that are not the same as axes objects. I would need to research to find out whether it is possible to draw into them... maybe. But I will not be able to check that until after I have had some sleep. (Perhaps someone else will happen to know while I am sleeping.)

3 Commenti

Sorry, we don't have the Mind Reading Toolbox and Crystal Ball Toolbox like you. I have no idea where you got that code. All I can say is that when she calls axes(H) make sure H is an axes, like it came from a line like
H = axes(); % or
H = subplot(2, 2, 1);
or something like that and NOT H=colorbar. Then you can add a colorbar to a particular axes like this:
colorbar(H);
Not sure what v is but if you want the colors in the colorbar, you can make up a colormap in advance like
cMap = hsv(256); % Create a colormap using the HSV color pattern
colormap(H, cMap); % Apply the colormap to the axes. DOes not automatically show the colorbar.
colorbar(H); % Display the colorbar next to the axes.
The code is in Neurospec20 (user mention) function psptf_ch1 (in the error message). I think it is intended to draw 95% confidence interval lines directly on the colorbar
Thank you for your help!

Accedi per commentare.

Più risposte (1)

In current releases, if yout take
cb = colorbar();
LS = cb.DecorationContainer.NodeChildren(1).NodeChildren(1)
then LS will be a LineStrip object, which is an undocumented internal MATLAB object.
You can potentially modify LS.VertexData and LS.VertexIndices
The first two rows of LS.VertexData appear to be X and Y coordinates. I have not figured out what the third row means; it is not out of the question that it is Z data (for something that is being viewed from the top.)
So you could potentially add new lines by adding new vertex columns, to draw from where you are up one side of the color area, across to the other side, up that side, then back across to the other side to draw the confidence interval lines. I suspect you would end up adding 4 columns.

Categorie

Prodotti

Release

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by