Hello everybody,
I would like to know if someone figured out a smart way on how to overlay a 2D plot with a bar3 (top-down view) which are properly aligned in x-y position.
To give a quick motivation, I have a 2D space, e.g., x in [-100,100] and y in [-100 100] gridded with 10 bins each dimension. I have binned data given in a 10×10 matrix 'Z'. Now I would like to plot the values of the binned data on a 2D plane, with colored squares, where the size of the squares corresponds to the binsize, the bincenters to the 'true' location in the 2D space and the color to the value in Z.
0) It is not possible to use hist3 since the data is given as is (binned form). As far as I know a call like
hist3(Binned_Data,Bin_Centers),
1) The straight forward idea, which I would favour to use, would be to simply adjust the bar-positions in x-y, somthing like:
bar3(Y_Bar_Positions,X_Bar_Positions,Binned_Data)
however bar3 does only allows to adjust the Y_bar_Positions
bar3(Y_Bar_Positons,Binned_Data),
which only enables me to align the bars to the bincenters in one dimension (in the example case above Y_Bar_Positons=[-90,-70,…,70,90]). Unfortunately in the other dimension the bars are placed at [0,1,…,9,10].
2) A second approach would be to use the surf()-function, which does not the job I want, since it places the Z value at the grid points (bin centers) and linear interpolates, therefore producing a spiky plot. This does not give a constant colors over the squares when seen from top-down view.
3) In the end there would be the option to construct this by hand using the patch function, but this seems to be a rather intensive solution, which I would like to avoid if someone has a better idea.
Thanks a lot for any suggestions.
Stephan
Best Answer