Xclick, colorbar and ylabel

Hi,
Here the complete and minimal code showing my problem

f=scf(0);
f.color_map=hotcolormap(16);
Sgrayplot(1:10,1:20,rand(10,20))
colorbar;
ylabel(f.children(1),"legend")
[a,x0,y0]=xclick();
disp([x0,y0])
plot(x0,y0,"m.")

If I comment the line “ylabel…”, the disp and the plot do what I expected, but I need to write a ylabel to the colobar. How can I do that?

Thanks,
Jean-Yves

Hello,

I suggest recovering the current Axes after the grayplot and make it active before the xclick call:

f=scf(0);
f.color_map=hotcolormap(16);
Sgrayplot(1:10,1:20,rand(10,20))
ax = gca();
colorbar;
ylabel(f.children(1),"legend")
sca(ax);
[a,x0,y0]=xclick();
disp([x0,y0])
plot(x0,y0,"m.")

Great! Exactly what I want. Thanks!

1 Like