Is there an easier way to create this in pgfplots than plotting the matrix image externally and using addplot graphics
(as on p.42 of the pgfplots
manual)?
A mesh plot (as suggested for plotting matrixes here) might not support the number of data points I'd like to use, plotting 1000×500 points this way won't work, or create a giantic output file.
Getting the upper/lower limits for the colorbar and the palette right isn't that straightforward when using two plotting programs (the gnuplot print
statement can be redirected into a file, which allows generating TeX-code from gnuplot, so the limits as determined by gnuplot could be imported as macros etc.)
Since pgfplots can call gnuplot for line-data already, passing commands and reading back the output, could I use this to write the gnuplot code to generate the image directly into my TeX file instead of having to run an external script and manage the temporary files manually?
set terminal tikz standalone externalimages
set output "plot.tex"
plot "data.dat" matrix with image
set print "plot-params.tex"
print sprintf("\cb{%g}{%g}",GPVAL_CB_MIN,GPVAL_CB_MAX)
The style of gnuplot's tikz output doesn't match pgfplots' style and draws the color bars as a series of boxes instead of a gradient but it automatically generates the pixel data as plot.0.png
in the correct size, which makes it a bit easier to use with addplot graphics
.
This gets worse when multiple such plots should be combined using multiplot
/groupplots
.
Best Answer
As the sample matrix datasets(131*131) are large in size
LuaLaTeX -shell-escape
approach was adopted andpdflatex
fails due to memory limitations. I have retained the TeX memory defaults on TeXLive 2012 frozen. In view of your real datasets of size (1000x500) points. I made some points to help you.TeX memory problems in pgfplots can be resolved by(More info at Section 6.1 pgfplots manual revision 1.8, 17/3/2013)
1)How to expand TeX's "main memory size"? (pgfplots memory overload) and How can one predict pgfplots memory overload?
2)Downsampling the data using
gnuplot
orsed
as discussed in pgfplot: plotting a large dataset.3)Export separate figure pdf's using pgfplots externalize library to reduce the compilation time and avoid memory problems for large documents.
4)Alternatively use fully gnuplot solution using gnuplottex package via improved terminal exports
epslatex
,pdf
, andlua/tikz
.gnuplot lua/tikz terminal driver
Examples:
A tikz terminal can export full-plot.tex of plot like in this TeXample.net example and gnuplottikz example
Hoping this works for you.
code compiled with
lualatex -shell-escape
, gnuplot 4.4.3 and pgfplots 1.8code compiled with
pdflatex -shell-escape
, gnuplot 4.4.3 and gnuplottex(version October 2, 2012)I have failed to get result in this way. Anybody can give their feedback.
\addplot3[surf,mesh/cols=131,mesh/ordering=rowwise,shader=interp] file {mat-data.dat};