Reverse the colorbar in an Octave figure
Sometimes we want to reverse the direction of the color bar in an Octave figure, which is plotted by imagesc
or surf
for example. This can be solved by treating the color bar as an axis object, then setting its ij
option. This method is obtained from a hint from the documentation:
Implementation Note: A colorbar is created as an additional axes to the current figure with the “tag” property set to “colorbar”. The created axes object has the extra property “location” which controls the positioning of the colorbar.
An example is given as follows.
figure(1, "visible", "off"); imagesc(toeplitz([1:100]')); cb = colorbar; axis(cb, "ij"); img_name = "figures/2022-05-29-octave-reversed-colorbar.png"; PrintGCF(img_name); ans = img_name;