I have a code which gets two parameters and depending on them the code has different runtimes what I want to illustrate in a matrix plot.
I'm writing the thesis in LaTeX the obvious method for me, was to use pgfplots
. Since the data set is too large I couldn't compile it and alternatives like LuaLaTeX
or externalize
provided by pgfplots don't work for me at the moment.
I decided to use gnuplot
and found a way using the packages gnuplottex
and epstopdf
. I don't want to include the plots as images because I want the ability to change the data set throughout my working process. My first result was:
\documentclass{scrbook}
\usepackage{graphicx, gnuplottex, epstopdf}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
\begin{figure}
\centering
\begin{gnuplot}[terminal=epslatex]
set autoscale fix
set xtics 1
set ytics 1
set palette defined (0 'red', 1 'orange', 2 'yellow', 5 'green', 10 'blue')
set logscale cb
unset key
plot 'data' matrix using ($1+2):($2+2):3 with image
\end{gnuplot}
\end{figure}
\end{document}
This looks pretty good, but then I have the gnuplot appearance and not the one I worked out for the other plots in my thesis which I would like to apply here too. So I continued searching and found a way where gnuplot is invoked through pgfplots
(Easiest way to plot matrix image).
But I don't get that to work. I tried to transfer the code from above:
\documentclass{scrbook}
\usepackage{graphicx}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}
\begin{axis}[colorbar]
\addplot [raw gnuplot, surf, shader=interp] gnuplot [id={surf}]
{
set autoscale fix;
unset key;
plot 'data' matrix with image;
};
\end{axis}
\end{tikzpicture}
\end{figure}
\end{document}
I get an output, but it looks not really like a matrixplot. There are lines running from one end to another:
The version from the link above, which is essentially this:
\begin{tikzpicture}
\begin{axis}
\addplot3 [raw gnuplot,surf,shader=interp] gnuplot [id={surf}]{
set pm3d map;
splot 'data' matrix;
};
\end{axis}
\end{tikzpicture}
results in empty axes with the warnings:
the current plot has no coordinates (or all have been filtered away)
You have an axis with empty range (in direction z). Replacing it with a default range and clearing all plots.
I tried various dataformats:
matrix formats like
0.000352994 0.000742189 0.000634092 ...
0.001709539 0.000348077 0.000179216 ...
0.00379762 0.00071006 8.2598e-05 ...
...
or the one mentioned earlier https://stackoverflow.com/questions/12750005/gnuplot-3d-plot-of-a-matrix-of-data
10 1 2 3 4 5 6 7 8 9 10
2 0.000352994 0.000742189 0.000634092 ...
3 0.001709539 0.000348077 0.000179216 ...
4 0.00379762 0.00071006 8.2598e-05 ...
...
or XYZ versions like
0 0 0.000352994
0 1 0.000742189
0 2 0.000634092
...
1 0 0.001709539
...
or with the actual parameters as supporting points
1 2 0.000352994
1 3 0.000742189
1 4 0.000634092
...
2 2 0.001709539
...
I use these versions:
pdfTeX 3.1415926-2.5-1.40.14 (TeX Live 2013)
Gnuplot Version 4.6 patchlevel 4
edit: I have now enough reputation to add the figures for the code examples. Also I edited code after the useful comment of @Christoph concerning the numbering of the tics.
set xtics 1; set ytics 1; plot 'data' matrix using ($1+1):($2+2):3 with image
.image
plotting style can be used. If you want to set several tics (taken from a word list you can also use iterations likeset for [i=1:10] xtics add ...
.