Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

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

📅 2014-May-12 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ bar, matlab, plot ⬩ 📚 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 8.1.0.604 (R2013a)


© 2022 Ashwin Nanjappa • All writing under CC BY-SA license • 🐘 @codeyarns@hachyderm.io📧