Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

How to color by bar height in 3D bar plot of Matlab

📅 2014-May-12 ⬩ ✍️ Ashwin Nanjappa ⬩ 📚 Archive

3D bar plots can be created easily in Matlab using the bar3 function. The bar columns in the plot are colored based on the row and column they belong to. It might sometimes be more useful to see the color of the bar column be based on the value (or z or height) of that bar column.

One way to do this is to use the bar3c function written by Gunther Struyf. Download his bar3c.m file from here, place it in the Matlab directory you are working from and call the function passing it the data.

Tried with: Matlab (R2013a)