close all;

function cb_fig_colormap (hf, ~)
  fprintf (stderr, "Figure callback executed\n");
  fflush (stderr);
endfunction

function cb_axes_colormap (hf, ~)
  fprintf (stderr, "Axes callback executed\n");
  fflush (stderr);
endfunction

hf = figure ();
hax = gca ();
addlistener (hf, "colormap", @cb_fig_colormap);
addlistener (hax, "colormap", @cb_axes_colormap);

fprintf (stderr, "changing Axes colormap\n");
set (hax, "colormap", jet (8));
assert (get (hax, "colormap"), jet(8));
fprintf (stderr, "changing Figure colormap\n");
set (hf, "colormap", jet (16));
assert (get (hf, "colormap"), jet(16));

