Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fails with yyplot #12

Closed
raacampbell opened this issue Feb 8, 2018 · 11 comments
Closed

Fails with yyplot #12

raacampbell opened this issue Feb 8, 2018 · 11 comments
Labels

Comments

@raacampbell
Copy link
Owner

raacampbell commented Feb 8, 2018

See also #3

Error using matlab.graphics.axis.Axes/set 
Children may only be set to a permutation of itself

Error in uistack (line 134) 
set(UParent,'Children',AllChildren);

Error in shadedErrorBar>makePlot (line 193) 
uistack(H.mainLine,'top') % Bring the main line to the top

Error in shadedErrorBar (line 126) 
H = makePlot(x,y,errBar,lineProps,transparent,patchSaturation);
@djsmith17
Copy link

I believe this has something to do with line 194:

uistack(H.mainLine,'top') % Bring the main line to the top

I commented out this line, and I was able to get this to work with yyaxis

@raacampbell
Copy link
Owner Author

IIRC, commenting out that line will cause the plot line to be hidden behind the shaded error region. I think it's also possible to perform the same operation by reordering the axis children (which are the plotted objects).

Can you send me the minimal example that generates the error?

@hollyhue
Copy link

Was this issue ever resolved? I would like to use plotyy with shaded error bars.

@raacampbell
Copy link
Owner Author

I haven't worked on it, no. Can you post a minimal example I can run that shows the problem?

@hollyhue
Copy link

hollyhue commented Nov 21, 2019

Hello! Below is an example that gives the error (granted you do get a plot even with the error, but in my application I use "hold on" to plot multiple things on on axis, with this application it will only plot one variable then stop due to the error):

% given shadedErrorBar is present in current path

X1=[1:120];
Y11=randi([0 1],120,1);
Y12=randi([0 1],120,1);
Y13=randi([0 1],120,1);

Y1=[Y11,Y12,Y13];

avgY1=mean(Y1,2);
stdv1=std(Y1,0,2);

Y21=10^-6 * randi([0 1],120,1);
Y22=10^-6 * randi([0 1],120,1);
Y23=10^-6 * randi([0 1],120,1);

Y2=[Y21,Y22,Y23];

avgY2=mean(Y2,2);
stdv2=std(Y2,0,2);
%%

figure(1), clf

yyaxis left
axis([0 120 -5 7])

shadedErrorBar(X1,avgY1,stdv1)

yyaxis right
axis([0 120 -510^-6 210^-6])

shadedErrorBar(X1,avgY2,stdv2)

@hollyhue
Copy link

It looks like someone has attempted to create a program that works with your program to resolve this issue -- but I cannot get it to work because I do not know what c1 and c2 are (same problem as person who commented on that program): https://www.mathworks.com/matlabcentral/fileexchange/42578-shaded-error-bar-yy

@raacampbell
Copy link
Owner Author

Ok. Thanks for the example code. I'll look into it.

@raacampbell
Copy link
Owner Author

raacampbell commented Nov 25, 2019

This example is more brief:

figure(1)
clf
y=rand(30,100);

yyaxis left
shadedErrorBar([],y,{@mean, @std},'lineProps','-b')

yyaxis right
shadedErrorBar([],y+4,{@(x) mean(x), @(x) std(x)*1.96},'lineProps','-r')
ylim([0,6])

@raacampbell
Copy link
Owner Author

Or, more generally:

clf 
yyaxis left
p1=plot(rand(1,199));
yyaxis right
p2=plot(rand(1,199));
uistack(p1,'top') %Generates error

The error being:

>> uistack(p1,'top')
Error using matlab.graphics.axis.Axes/set
Children may only be set to a permutation of itself

Error in uistack (line 157)
            set(UParent,'Children',AllChildren);

@raacampbell
Copy link
Owner Author

@hollyhue can you please pull the latest version and see if it works for you?

@hollyhue
Copy link

@raacampbell it works!!! Sorry for the 3 month delay in replying....oops.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants