I am trying to create a heatmap using tikz/pgfplots in latex, I however get an empty plot. I use the same command as I used in GNUplot, which was
plot 'heat-data.txt' matrix with image;
In GNUplot this results in the desired image where 'heat-data.txt' a file is containing the z coordinates.
6 5 4 3 1 0
3 2 2 0 0 1
0 0 0 0 1 0
0 0 0 0 2 3
0 0 1 1 1 0
0 1 0 1 1 0
Since I would like to generate heat maps of data sets in a report, I'd like to do this in the same style as the rest of the report and therefor use Tikz/Pgfplots. I have tried
\addplot3[raw gnuplot]
gnuplot{
set view map;
plot 'heat-data.txt' matrix with image};
and have tried
\addplot3[raw gnuplot,surf,shader=flat]gnuplot{
plot 'heat-data.txt' matrix with image;
};
MWE:
\documentclass[tikz, crop]{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\pgfplotsset{plot coordinates/math parser=false}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
colorbar right,
colormap/viridis,
view={0}{90}
]
%\addplot3[raw gnuplot]gnuplot{
%plot 'heat-data.txt' matrix with image;
%};
\addplot3[raw gnuplot,surf,shader=flat]gnuplot{
plot 'heat-data.txt' matrix with image;
};
\end{axis}
\end{tikzpicture}
\end{document}
\begin{axis}[view={0}{90}, colorbar, colormap name=viridis] \addplot3 [raw gnuplot,surf,mesh/rows=6,mesh/cols=6] gnuplot { plot 'heat-data.txt' matrix with image; };
which results in a heat map plot.