Let's say we have some discrete parameter, according to which we want to make a coloring on the plot using Plots.jl with GR backend. The parameter type (in the example below, it is Int64) clearly indicates that it is discrete, but if we do not take any additional actions, a continuous color scale will be applied to it in colorbar. If we explicitly specify the number of color gradations corresponding to the number of discrete classes, or at least just explicitly set the palette, then in this case the intermediate color gradations will disappear, but the scale will essentially remain continuous. What is the right way to make a colorbar for discrete data, where each class will correspond to a separate color and the value of that class?
x = (1:1:7); y = (1:1:7); z = [0, 1, 2, 2, 1, 0, 0]
plot(x, y, zcolor = z, seriestype = :scatter,
markersize=5, label = "points")
result:
x = (1:1:7); y = (1:1:7); z = [0, 1, 2, 2, 1, 0, 0]
plot(x, y, zcolor = z, seriestype = :scatter,
markersize=5, label = "points", color=palette(:heat, 3))
or
x = (1:1:7); y = (1:1:7); z = [0, 1, 2, 2, 1, 0, 0]
plot(x, y, zcolor = z, seriestype = :scatter,
markersize=5, label = "points", color=palette(:heat))
result: