Did you mean something like this?

- HSV histogram shown as 3D
V ignored to get to 3D (otherwise it will be a 4D chart ...)
, if yes, then how to do it (I do not use OpenCV, so configure it to your needs):
- convert source image to hsv
- calculate a histogram ignoring the value of V
- all colors with the same H, S are treated as one color no matter what V
- you can ignore any other, but parameter V looks like the best choice
draw a graph
- first draw an ellipse with a darker color (basic HSV disk)
- then for each point, take the corresponding histogram value and draw a vertical line with a brighter color. The line size is proportional to the histogram value.
Here is the C ++ code I made using:
picture pic0,pic1,pic2,zed; int his[65536]; DWORD w; int h,s,v,x,y,z,i,n; double r,a; color c;
- input image
pic0 (rose), output image pic1 (bar graph) pic2 is pic0 converted to HSV for histogram calculationzed is the Zed buffer for the 3D display, eliminating the sorting of Z ...
I use my own image class for images, so some members:
xs,ys image size in pixelsp[y][x].dd - pixel at position (x, y) as a 32-bit integer typeclear(color) - clears the entire imageresize(xs,ys) - resize the image to a new resolutionrgb2hsv() and hsv2rgb() ... guess what it does :)
[edit1] your two-dimensional histogram
It looks like you have a color-coded 2D array. One axis is H and the second is S Therefore, you need to calculate the value of H,S from the address of the array. If it is linear, then for HSV[i][j] :
H=h0+(h1-h0)*i/maxiS=s0+(s1-s0)*j/maxj- or
i,j canceled h0,h1,s0,s1 - color rangesmaxi,maxj - array size
As you can see, you also drop V as I do, so now you have H,S for each cell in the 2D histogram array. Where probability is the value of the cell. Now, if you want to draw an image, you need to know how to display it (as a 2D graph, 3D, display, ...). For unsorted graphics drawing 2D graphics, where:
x=i+maj*iy=HSV[i][j]color=(H,S,V=200);
If you want to sort it, just calculate the x axis differently or loop the 2D array in sort order and x just increase
[edit2] updating code and some images
I restored the C ++ code above (the wrong sign of the Z value, changed the state of the Z-buffer and added more points for a more pleasant output). The colors of the 2D array can be as follows:

If one axis / index is H , the remaining S and Value fixed (I select 200). If your axes exchange, then just flip it to y=x , I think ...
Sorting colors is just the order in which you select all the colors from an array. eg:
v=200; x=0; for (h=0;h<256;h++) for (s=0;s<256;s++,x++) { y=HSV[h][s]; // here draw line (x,0)->(x,y) by color hsv2rgb(h,s,v); }
This is an incremental path. You can compute x from H,S instead to achieve different sorting or fors replacement ( x++ should be in the inner loop)
If you want a graph of the RGB histogram, look: