Plots.jl: How can I get discrete colors in the colorbar of a heatmap?

It can be done with GMT.jl

using GMT
r = rand(0:10,10,10);
C=makecpt(range=(0,10,1));
imshow(r, cmap=C, colorbar=true)

and one gets the fig bellow. Note that the fact that the border pixels are cut in half is not wrong. The issue is that there are 2 ways to referencing grids (this is a grid plot since data is not uint8). They are called grid and pixel registration in GMT vocabulary or AREA_OR_POINT=Area and AREA_OR_POINT=Point in GeoTiff. Some more info at

But we can get a non-clipped version with

G = mat2grid(r, 1);       # Create a pixel registered grid
imshow(G, cmap=C, colorbar=true)