我必须绘制一个大数据集的轮廓图,因此我使用路拉泰克斯作为编译器。此示例也适用于普通乳胶即 latex+dvips+ps2pdf。它在乳胶但对于我拥有的大量数据,我需要使用路拉泰克斯。
我想要绘制从一些 matlab 计算中读取的 2D 轮廓。由于轮廓线非常紧密,我不希望在图中标注,但高度不能完全忽略,应该提及。
因此,我正在寻找的是(最好)用于高度值的彩色条或用于显示高度的其他类型的图例(我主要对数量级感兴趣,而不是这里的一些花哨的细节)。唉,彩色条样式只会产生一个空条。如何才能正确做到这一点?
我最好坚持使用给定的数据格式,而不是使用任何非标准数据输出自己计算点元信息。
看一下我的 MWE(由于数据太多所以相当大):
\documentclass{article}
\usepackage{pgfplots}
\usepackage{filecontents}
\pgfplotsset{compat=1.10}
\usepgfplotslibrary{colormaps}
\listfiles
\begin{document}
\begin{filecontents*}{contours.txt}
% contours in matlab export format:
% first line: height value | number of points
% empty line: new height contour
% ( -8.000000e-01, +27) ==> contour ' -8.000000e-01', consists of 27 points
% first line is reserved for height value and number of values
-8.000000e-01 +2.700000e+01
+9.298664e-01 +3.100000e+00
+9.425839e-01 +3.000000e+00
+9.698291e-01 +2.900000e+00
+1.000000e+00 +2.829558e+00
+1.015251e+00 +2.800000e+00
+1.087289e+00 +2.700000e+00
+1.100000e+00 +2.686407e+00
+1.200000e+00 +2.603061e+00
+1.204984e+00 +2.600000e+00
+1.300000e+00 +2.552224e+00
+1.400000e+00 +2.519138e+00
+1.500000e+00 +2.501552e+00
+1.551839e+00 +2.500000e+00
+1.600000e+00 +2.498741e+00
+1.612658e+00 +2.500000e+00
+1.700000e+00 +2.510011e+00
+1.800000e+00 +2.536488e+00
+1.900000e+00 +2.579387e+00
+1.934295e+00 +2.600000e+00
+2.000000e+00 +2.648558e+00
+2.052969e+00 +2.700000e+00
+2.100000e+00 +2.759507e+00
+2.125867e+00 +2.800000e+00
+2.171795e+00 +2.900000e+00
+2.200000e+00 +2.997366e+00
+2.200652e+00 +3.000000e+00
+2.212428e+00 +3.100000e+00
% ( -6.000000e-01, +36) ==> contour ' -6.000000e-01', consists of 36 points
% first line is reserved for height value and number of values
-6.000000e-01 +3.600000e+01
+6.450855e-01 +3.100000e+00
+6.520548e-01 +3.000000e+00
+6.669855e-01 +2.900000e+00
+6.906688e-01 +2.800000e+00
+7.000000e-01 +2.771533e+00
+7.265882e-01 +2.700000e+00
+7.765533e-01 +2.600000e+00
+8.000000e-01 +2.563254e+00
+8.478595e-01 +2.500000e+00
+9.000000e-01 +2.444816e+00
+9.521974e-01 +2.400000e+00
+1.000000e+00 +2.365752e+00
+1.100000e+00 +2.309798e+00
+1.122826e+00 +2.300000e+00
+1.200000e+00 +2.271037e+00
+1.300000e+00 +2.243961e+00
+1.400000e+00 +2.226175e+00
+1.500000e+00 +2.216722e+00
+1.600000e+00 +2.215114e+00
+1.700000e+00 +2.221269e+00
+1.800000e+00 +2.235502e+00
+1.900000e+00 +2.258563e+00
+2.000000e+00 +2.291738e+00
+2.019028e+00 +2.300000e+00
+2.100000e+00 +2.340503e+00
+2.190532e+00 +2.400000e+00
+2.200000e+00 +2.407411e+00
+2.294865e+00 +2.500000e+00
+2.300000e+00 +2.506214e+00
+2.364773e+00 +2.600000e+00
+2.400000e+00 +2.666529e+00
+2.415326e+00 +2.700000e+00
+2.450228e+00 +2.800000e+00
+2.474706e+00 +2.900000e+00
+2.490138e+00 +3.000000e+00
+2.497341e+00 +3.100000e+00
% ( -4.000000e-01, +47) ==> contour ' -4.000000e-01', consists of 47 points
% first line is reserved for height value and number of values
-4.000000e-01 +4.700000e+01
+4.121411e-01 +3.100000e+00
+4.162488e-01 +3.000000e+00
+4.250489e-01 +2.900000e+00
+4.390079e-01 +2.800000e+00
+4.589111e-01 +2.700000e+00
+4.859784e-01 +2.600000e+00
+5.000000e-01 +2.559536e+00
+5.233061e-01 +2.500000e+00
+5.739589e-01 +2.400000e+00
+6.000000e-01 +2.359249e+00
+6.448749e-01 +2.300000e+00
+7.000000e-01 +2.241668e+00
+7.485041e-01 +2.200000e+00
+8.000000e-01 +2.163065e+00
+9.000000e-01 +2.106929e+00
+9.154680e-01 +2.100000e+00
+1.000000e+00 +2.066755e+00
+1.100000e+00 +2.036846e+00
+1.200000e+00 +2.014678e+00
+1.292516e+00 +2.000000e+00
+1.300000e+00 +1.998903e+00
+1.400000e+00 +1.988971e+00
+1.500000e+00 +1.983693e+00
+1.600000e+00 +1.982795e+00
+1.700000e+00 +1.986232e+00
+1.800000e+00 +1.994179e+00
+1.845915e+00 +2.000000e+00
+1.900000e+00 +2.007387e+00
+2.000000e+00 +2.026780e+00
+2.100000e+00 +2.053259e+00
+2.200000e+00 +2.088613e+00
+2.225761e+00 +2.100000e+00
+2.300000e+00 +2.137725e+00
+2.393978e+00 +2.200000e+00
+2.400000e+00 +2.204738e+00
+2.497559e+00 +2.300000e+00
+2.500000e+00 +2.302942e+00
+2.567519e+00 +2.400000e+00
+2.600000e+00 +2.460471e+00
+2.618401e+00 +2.500000e+00
+2.655260e+00 +2.600000e+00
+2.682907e+00 +2.700000e+00
+2.700000e+00 +2.783521e+00
+2.703086e+00 +2.800000e+00
+2.716685e+00 +2.900000e+00
+2.725258e+00 +3.000000e+00
+2.729260e+00 +3.100000e+00
% ( -2.000000e-01, +55) ==> contour ' -2.000000e-01', consists of 55 points
% first line is reserved for height value and number of values
-2.000000e-01 +5.500000e+01
+2.015527e-01 +3.100000e+00
+2.034614e-01 +3.000000e+00
+2.075505e-01 +2.900000e+00
+2.140368e-01 +2.800000e+00
+2.232852e-01 +2.700000e+00
+2.358626e-01 +2.600000e+00
+2.526312e-01 +2.500000e+00
+2.749154e-01 +2.400000e+00
+3.000000e-01 +2.314760e+00
+3.049582e-01 +2.300000e+00
+3.472067e-01 +2.200000e+00
+4.000000e-01 +2.110448e+00
+4.074905e-01 +2.100000e+00
+5.000000e-01 +2.001149e+00
+5.013777e-01 +2.000000e+00
+6.000000e-01 +1.933295e+00
+6.678578e-01 +1.900000e+00
+7.000000e-01 +1.886642e+00
+8.000000e-01 +1.853701e+00
+9.000000e-01 +1.829264e+00
+1.000000e+00 +1.810904e+00
+1.078017e+00 +1.800000e+00
+1.100000e+00 +1.797166e+00
+1.200000e+00 +1.787170e+00
+1.300000e+00 +1.780034e+00
+1.400000e+00 +1.775346e+00
+1.500000e+00 +1.772854e+00
+1.600000e+00 +1.772430e+00
+1.700000e+00 +1.774053e+00
+1.800000e+00 +1.777804e+00
+1.900000e+00 +1.783883e+00
+2.000000e+00 +1.792627e+00
+2.062975e+00 +1.800000e+00
+2.100000e+00 +1.804674e+00
+2.200000e+00 +1.820992e+00
+2.300000e+00 +1.842670e+00
+2.400000e+00 +1.871696e+00
+2.473804e+00 +1.900000e+00
+2.500000e+00 +1.911733e+00
+2.600000e+00 +1.969658e+00
+2.639606e+00 +2.000000e+00
+2.700000e+00 +2.058423e+00
+2.733790e+00 +2.100000e+00
+2.794742e+00 +2.200000e+00
+2.800000e+00 +2.210974e+00
+2.836362e+00 +2.300000e+00
+2.866601e+00 +2.400000e+00
+2.889144e+00 +2.500000e+00
+2.900000e+00 +2.562435e+00
+2.905958e+00 +2.600000e+00
+2.918372e+00 +2.700000e+00
+2.927500e+00 +2.800000e+00
+2.933901e+00 +2.900000e+00
+2.937937e+00 +3.000000e+00
+2.939821e+00 +3.100000e+00
% ( +0.000000e+00, +47) ==> contour ' +0.000000e+00', consists of 47 points
% first line is reserved for height value and number of values
+0.000000e+00 +4.700000e+01
+0.000000e+00 +3.100000e+00
+0.000000e+00 +3.000000e+00
+0.000000e+00 +2.900000e+00
+0.000000e+00 +2.800000e+00
+0.000000e+00 +2.700000e+00
+0.000000e+00 +2.600000e+00
+0.000000e+00 +2.500000e+00
+0.000000e+00 +2.400000e+00
+0.000000e+00 +2.300000e+00
+0.000000e+00 +2.200000e+00
+0.000000e+00 +2.100000e+00
+0.000000e+00 +2.000000e+00
+0.000000e+00 +1.900000e+00
+0.000000e+00 +1.800000e+00
+0.000000e+00 +1.700000e+00
+0.000000e+00 +1.600000e+00
+1.000000e-01 +1.570782e+00
+2.000000e-01 +1.570782e+00
+3.000000e-01 +1.570782e+00
+4.000000e-01 +1.570782e+00
+5.000000e-01 +1.570782e+00
+6.000000e-01 +1.570782e+00
+7.000000e-01 +1.570782e+00
+8.000000e-01 +1.570782e+00
+9.000000e-01 +1.570782e+00
+1.000000e+00 +1.570782e+00
+1.100000e+00 +1.570782e+00
+1.200000e+00 +1.570782e+00
+1.300000e+00 +1.570782e+00
+1.400000e+00 +1.570782e+00
+1.500000e+00 +1.570782e+00
+1.600000e+00 +1.570782e+00
+1.700000e+00 +1.570782e+00
+1.800000e+00 +1.570782e+00
+1.900000e+00 +1.570782e+00
+2.000000e+00 +1.570782e+00
+2.100000e+00 +1.570782e+00
+2.200000e+00 +1.570782e+00
+2.300000e+00 +1.570782e+00
+2.400000e+00 +1.570782e+00
+2.500000e+00 +1.570782e+00
+2.600000e+00 +1.570782e+00
+2.700000e+00 +1.570782e+00
+2.800000e+00 +1.570782e+00
+2.900000e+00 +1.570782e+00
+3.000000e+00 +1.570782e+00
+3.100000e+00 +1.570782e+00
% ( +2.000000e-01, +55) ==> contour ' +2.000000e-01', consists of 55 points
% first line is reserved for height value and number of values
+2.000000e-01 +5.500000e+01
+2.013739e-01 +0.000000e+00
+2.024108e-01 +1.000000e-01
+2.055740e-01 +2.000000e-01
+2.110283e-01 +3.000000e-01
+2.190722e-01 +4.000000e-01
+2.301799e-01 +5.000000e-01
+2.450758e-01 +6.000000e-01
+2.648652e-01 +7.000000e-01
+2.912697e-01 +8.000000e-01
+3.000000e-01 +8.265445e-01
+3.279292e-01 +9.000000e-01
+3.794935e-01 +1.000000e+00
+4.000000e-01 +1.030812e+00
+4.572205e-01 +1.100000e+00
+5.000000e-01 +1.139929e+00
+5.850948e-01 +1.200000e+00
+6.000000e-01 +1.208593e+00
+7.000000e-01 +1.254717e+00
+8.000000e-01 +1.288085e+00
+8.459457e-01 +1.300000e+00
+9.000000e-01 +1.312486e+00
+1.000000e+00 +1.330574e+00
+1.100000e+00 +1.344175e+00
+1.200000e+00 +1.354255e+00
+1.300000e+00 +1.361452e+00
+1.400000e+00 +1.366179e+00
+1.500000e+00 +1.368692e+00
+1.600000e+00 +1.369120e+00
+1.700000e+00 +1.367483e+00
+1.800000e+00 +1.363700e+00
+1.900000e+00 +1.357570e+00
+2.000000e+00 +1.348752e+00
+2.100000e+00 +1.336711e+00
+2.200000e+00 +1.320635e+00
+2.296876e+00 +1.300000e+00
+2.300000e+00 +1.299258e+00
+2.400000e+00 +1.269856e+00
+2.500000e+00 +1.229700e+00
+2.556082e+00 +1.200000e+00
+2.600000e+00 +1.171926e+00
+2.684634e+00 +1.100000e+00
+2.700000e+00 +1.083425e+00
+2.761928e+00 +1.000000e+00
+2.800000e+00 +9.302234e-01
+2.813832e+00 +9.000000e-01
+2.850056e+00 +8.000000e-01
+2.876767e+00 +7.000000e-01
+2.896787e+00 +6.000000e-01
+2.900000e+00 +5.796880e-01
+2.911567e+00 +5.000000e-01
+2.922530e+00 +4.000000e-01
+2.930469e+00 +3.000000e-01
+2.935852e+00 +2.000000e-01
+2.938974e+00 +1.000000e-01
+2.939998e+00 +0.000000e+00
% ( +4.000000e-01, +47) ==> contour ' +4.000000e-01', consists of 47 points
% first line is reserved for height value and number of values
+4.000000e-01 +4.700000e+01
+4.117565e-01 +0.000000e+00
+4.139878e-01 +1.000000e-01
+4.207952e-01 +2.000000e-01
+4.325333e-01 +3.000000e-01
+4.498443e-01 +4.000000e-01
+4.737488e-01 +5.000000e-01
+5.000000e-01 +5.827813e-01
+5.061323e-01 +6.000000e-01
+5.511144e-01 +7.000000e-01
+6.000000e-01 +7.828193e-01
+6.119223e-01 +8.000000e-01
+6.990859e-01 +9.000000e-01
+7.000000e-01 +9.008632e-01
+8.000000e-01 +9.787218e-01
+8.348187e-01 +1.000000e+00
+9.000000e-01 +1.034207e+00
+1.000000e+00 +1.074902e+00
+1.081170e+00 +1.100000e+00
+1.100000e+00 +1.105225e+00
+1.200000e+00 +1.126776e+00
+1.300000e+00 +1.142162e+00
+1.400000e+00 +1.152270e+00
+1.500000e+00 +1.157642e+00
+1.600000e+00 +1.158556e+00
+1.700000e+00 +1.155058e+00
+1.800000e+00 +1.146970e+00
+1.900000e+00 +1.133864e+00
+2.000000e+00 +1.115011e+00
+2.059572e+00 +1.100000e+00
+2.100000e+00 +1.088708e+00
+2.200000e+00 +1.052542e+00
+2.300000e+00 +1.004495e+00
+2.307658e+00 +1.000000e+00
+2.400000e+00 +9.361881e-01
+2.441528e+00 +9.000000e-01
+2.500000e+00 +8.377354e-01
+2.529339e+00 +8.000000e-01
+2.590982e+00 +7.000000e-01
+2.600000e+00 +6.816485e-01
+2.635009e+00 +6.000000e-01
+2.667752e+00 +5.000000e-01
+2.692168e+00 +4.000000e-01
+2.700000e+00 +3.566031e-01
+2.709394e+00 +3.000000e-01
+2.720829e+00 +2.000000e-01
+2.727461e+00 +1.000000e-01
+2.729635e+00 +0.000000e+00
% ( +6.000000e-01, +38) ==> contour ' +6.000000e-01', consists of 38 points
% first line is reserved for height value and number of values
+6.000000e-01 +3.800000e+01
+6.444328e-01 +0.000000e+00
+6.482186e-01 +1.000000e-01
+6.597684e-01 +2.000000e-01
+6.796837e-01 +3.000000e-01
+7.000000e-01 +3.699459e-01
+7.098511e-01 +4.000000e-01
+7.539780e-01 +5.000000e-01
+8.000000e-01 +5.788139e-01
+8.145836e-01 +6.000000e-01
+9.000000e-01 +6.981460e-01
+9.019755e-01 +7.000000e-01
+1.000000e+00 +7.760325e-01
+1.039656e+00 +8.000000e-01
+1.100000e+00 +8.312433e-01
+1.200000e+00 +8.705182e-01
+1.300000e+00 +8.985591e-01
+1.307662e+00 +9.000000e-01
+1.400000e+00 +9.156823e-01
+1.500000e+00 +9.247248e-01
+1.600000e+00 +9.262632e-01
+1.700000e+00 +9.203755e-01
+1.800000e+00 +9.067609e-01
+1.831263e+00 +9.000000e-01
+1.900000e+00 +8.834369e-01
+2.000000e+00 +8.490788e-01
+2.100000e+00 +8.021655e-01
+2.103683e+00 +8.000000e-01
+2.200000e+00 +7.333510e-01
+2.238255e+00 +7.000000e-01
+2.300000e+00 +6.342651e-01
+2.326662e+00 +6.000000e-01
+2.388279e+00 +5.000000e-01
+2.400000e+00 +4.753975e-01
+2.431225e+00 +4.000000e-01
+2.461581e+00 +3.000000e-01
+2.482165e+00 +2.000000e-01
+2.494103e+00 +1.000000e-01
+2.498016e+00 +0.000000e+00
% ( +8.000000e-01, +27) ==> contour ' +8.000000e-01', consists of 27 points
% first line is reserved for height value and number of values
+8.000000e-01 +2.700000e+01
+9.286755e-01 +0.000000e+00
+9.355837e-01 +1.000000e-01
+9.566595e-01 +2.000000e-01
+9.930007e-01 +3.000000e-01
+1.000000e+00 +3.134802e-01
+1.054472e+00 +4.000000e-01
+1.100000e+00 +4.538252e-01
+1.149931e+00 +5.000000e-01
+1.200000e+00 +5.368432e-01
+1.300000e+00 +5.905824e-01
+1.326241e+00 +6.000000e-01
+1.400000e+00 +6.223554e-01
+1.500000e+00 +6.385605e-01
+1.600000e+00 +6.413175e-01
+1.700000e+00 +6.307660e-01
+1.800000e+00 +6.063674e-01
+1.816499e+00 +6.000000e-01
+1.900000e+00 +5.616013e-01
+1.993790e+00 +5.000000e-01
+2.000000e+00 +4.948996e-01
+2.088383e+00 +4.000000e-01
+2.100000e+00 +3.833321e-01
+2.147170e+00 +3.000000e-01
+2.185790e+00 +2.000000e-01
+2.200000e+00 +1.369073e-01
+2.207134e+00 +1.000000e-01
+2.213531e+00 +0.000000e+00\end{filecontents*}
\begin{tikzpicture}
\begin{axis}[colorbar, colormap/jet, colorbar horizontal]
\addplot
[
contour prepared,
contour prepared format=matlab,
/pgfplots/contour/labels=false,
]
table {contours.txt};
\end{axis}
\end{tikzpicture}
\end{document}
产生如下所示的输出(红色椭圆体标记问题区域,不属于 pgfplots 输出)
更新 1
根据下面的评论和讨论,我认为这是我正在使用的 pgfplots 版本的问题。仍然更新TeX 3.14159265(TeX Live 2014/W32TeX)没有产生不同的结果。我想我的 pgf 包是最新的,但为了确保这一点,我\listfiles
在上面的示例中添加了命令。如果您可以从我的示例中编译出一个填充的颜色条,我很乐意查看您的日志的文件部分以检测版本差异。这是我的文件列表:
*File List*
article.cls 2007/10/19 v1.4h Standard LaTeX document class
size10.clo 2007/10/19 v1.4h Standard LaTeX file (size option)
pgfplots.sty 2014/02/28 v1.10 Data Visualization (1.10-2-gb39fe75)
tikz.sty 2013/12/13 v3.0.0 (rcs-revision 1.142)
pgf.sty 2013/12/18 v3.0.0 (rcs-revision 1.14)
pgfrcs.sty 2013/12/20 v3.0.0 (rcs-revision 1.28)
everyshi.sty 2001/05/15 v3.00 EveryShipout Package (MS)
pgfrcs.code.tex
pgfcore.sty 2010/04/11 v3.0.0 (rcs-revision 1.7)
graphicx.sty 2014/04/25 v1.0g Enhanced LaTeX Graphics (DPC,SPQR)
keyval.sty 2014/05/08 v1.15 key=value parser (DPC)
graphics.sty 2009/02/05 v1.0o Standard LaTeX Graphics (DPC,SPQR)
trig.sty 1999/03/16 v1.09 sin cos tan (DPC)
graphics.cfg 2010/04/23 v1.9 graphics configuration of TeX Live
pdftex.def 2011/05/27 v0.06d Graphics/color for pdfTeX
infwarerr.sty 2010/04/08 v1.3 Providing info/warning/error messages (HO)
ltxcmds.sty 2011/11/09 v1.22 LaTeX kernel commands for general use (HO)
pdftexcmds.sty 2011/11/29 v0.20 Utility functions of pdfTeX for LuaTeX (HO)
ifluatex.sty 2010/03/01 v1.3 Provides the ifluatex switch (HO)
ifpdf.sty 2011/01/30 v2.3 Provides the ifpdf switch (HO)
luatex-loader.sty 2010/03/09 v0.4 Lua module loader (HO)
pgfsys.sty 2013/11/30 v3.0.0 (rcs-revision 1.47)
pgfsys.code.tex
pgfsyssoftpath.code.tex 2013/09/09 (rcs-revision 1.9)
pgfsysprotocol.code.tex 2006/10/16 (rcs-revision 1.4)
xcolor.sty 2007/01/21 v2.11 LaTeX color extensions (UK)
color.cfg 2007/01/18 v1.5 color configuration of teTeX/TeXLive
pgfcore.code.tex
pgfcomp-version-0-65.sty 2007/07/03 v3.0.0 (rcs-revision 1.7)
pgfcomp-version-1-18.sty 2007/07/23 v3.0.0 (rcs-revision 1.1)
pgffor.sty 2013/12/13 v3.0.0 (rcs-revision 1.25)
pgfkeys.sty
pgfkeys.code.tex
pgfmath.sty
pgfmath.code.tex
pgffor.code.tex
tikz.code.tex
filecontents.sty 2011/10/08 v1.3 Create an external file from within a LaTeX
document
supp-pdf.mkii
epstopdf-base.sty 2010/02/09 v2.5 Base part for package epstopdf
grfext.sty 2010/08/19 v1.1 Manage graphics extensions (HO)
kvdefinekeys.sty 2011/04/07 v1.3 Define keys (HO)
kvoptions.sty 2011/06/30 v3.11 Key value format for package options (HO)
kvsetkeys.sty 2012/04/25 v1.16 Key value parser (HO)
etexcmds.sty 2011/02/16 v1.5 Avoid name clashes with e-TeX commands (HO)
epstopdf-sys.cfg 2010/07/13 v1.3 Configuration of (r)epstopdf for TeX Live
***********
我在其他地方读到过,要使用 lualatex 进行插值着色,需要安装开发 pgfplots 包,但我没有安装(目前不需要进行插值着色)。也许这个空的颜色条是一个额外的错误?
答案1
这似乎是查看器的问题。在这种情况下,以及在出现其他意外显示问题(例如颜色渐变)的情况下,建议使用其他 PDF 查看器检查 PDF 输出。根据 OP,此特定示例由某些版本的 Adobe Acrobat 和 PDF-Xchange 正确呈现。
但是,我不知道为什么 lualatex 没有像 latex 那样渲染这个颜色条,如果有人有线索(可能是不同的 PDF 标题或页面配置?),请分享。