In addition to hpekristiansen great answer, i tried some further steps with his example and i would like to share my solution for producing such a 3d bar plot with colormap from an external file:
With
\documentclass[tikz, border=1cm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\usepgfplotslibrary{patchplots}
% define a colormap named "CM"
\pgfplotsset{colormap={CM}{
color=(blue!50!black)
color=(blue!50!white)
color=(cyan!70!white)
color=(green!50!yellow)
color=(orange!50!yellow)
color=(yellow)
}}
%Producing an example .csv file with same values
\begin{filecontents*}{Bar_Test_file.csv}
5,3,2,1,2,0.5,3
4,5,3,1,2,2,0.5
4,6,2,4,3,2,1
\end{filecontents*}
%Import file to save into variable "mytable for further processing
\pgfplotstableread[header=false, col sep = comma]{Bar_Test_file.csv}{\mytable}
\pgfplotstablegetrowsof{\mytable} %get number of rows
\pgfmathsetmacro{\rows}{\pgfplotsretval-1} %last "row" is number of rows minus 1 (0,1...)
\pgfplotstablegetcolsof{\mytable} %get number of cols
\pgfmathsetmacro{\cols}{\pgfplotsretval-1} %last "col" is number of cols minus 1 (0,1...)
\begin{document}
\begin{tikzpicture}
\newcommand{\barw}{0.4} %barwidth
\newcommand{\barl}{0.4} %barlength
%define a "boxbar"
\newcommand{\boxbar}[3]{
%% Coloring the bar
\addplot3[
patch,
shader=interp,
patch type=rectangle,
patch refines=2,
]
coordinates { (#1-\barw,#2-\barl,0) (#1-\barw,#2-\barl,#3) (#1+\barw,#2-\barl,#3) (#1+\barw,#2-\barl,0) (#1-\barw,#2-\barl,#3) (#1-\barw,#2+\barl,#3) (#1+\barw,#2+\barl,#3) (#1+\barw,#2-\barl,#3) (#1+\barw,#2-\barl,0) (#1+\barw,#2-\barl,#3) (#1+\barw,#2+\barl,#3) (#1+\barw,#2+\barl,0)};
%% Borders of a bar
\addplot3[
patch,
patch type=rectangle,
mesh, black, very thin,
]
coordinates { (#1-\barw,#2-\barl,0) (#1-\barw,#2-\barl,#3) (#1+\barw,#2-\barl,#3) (#1+\barw,#2-\barl,0) (#1-\barw,#2-\barl,#3) (#1-\barw,#2+\barl,#3) (#1+\barw,#2+\barl,#3) (#1+\barw,#2-\barl,#3) (#1+\barw,#2-\barl,0) (#1+\barw,#2-\barl,#3) (#1+\barw,#2+\barl,#3) (#1+\barw,#2+\barl,0)};
}
\begin{axis}[
colormap name = CM,
view={60}{30},
unit vector ratio=1.2 1 0.6,
xmin=0.4, xmax=3.6,
ymin=0.6, ymax=7.6,
zmin=0, zmax=6,
colorbar, colorbar/width=6pt,
xtick distance=1, ytick distance=1, ztick distance=1,
font=\tiny,
]
\foreach \j in {0,...,\rows}{%
\foreach \i in {0,...,\cols}{%
\pgfplotstablegetelem{\j}{[index] \i}\of{\mytable}
\let\myz\pgfplotsretval \boxbar{\j+1}{\cols+1-\i}{\myz}}}
\end{axis}
\end{tikzpicture}
\end{document}
it is possible to create the same plot from a .csv file.
I hope this will help someone for future 3D bar charts.