I assume you are trying to plot counts vs height for the whole image rather than the height of some particles. The data for a AFM image is a 2D matrix of height values where the index of an element represents the position of a pixel in the scan region. You can concatenate the elements in each row and generate a single row or 1D array. Now you can use excel or MATLAB to generate a histogram for this array. That would be the plot of counts vs height.