我正在使用 pgfplots 创建下面显示的四个轮廓图。我希望它们都共享一个共同的颜色条,范围从 -1 到 +1,而不是像现在这样,每个颜色条都调整到每个图的最大值和最小值。下面是我的 mwe(不是真的 w,因为我无法上传数据集)。
\documentclass{article}
\usepackage{pgfplots}
\usepackage{caption}
\usepackage{subcaption}
\begin{document}
\begin{figure}
\begin{subfigure}[b]{.44\textwidth}\centering
\begin{tikzpicture}
\begin{axis}[colormap/hot,
width =\textwidth, height=5cm, xlabel={$\theta/\pi$}, ylabel={$m\cdot g$},
legend pos = north west, colorbar, view={0}{90}]
\addplot3[contour lua, contour filled]
table [x=x, y=y,z=z, col sep=comma]{sites8mp4mm5qtot.csv};
\end{axis}
\end{tikzpicture}
\caption{..}
\end{subfigure}
\hfill
\begin{subfigure}[b]{.44\textwidth}\centering
\begin{tikzpicture}
\begin{axis}[colormap/hot, width =\textwidth, height=5cm, xlabel={$\theta/\pi$}, ylabel={$m\cdot g$},
legend pos = north west, colorbar, view={0}{90}]
\addplot3[contour lua, contour filled]
table [x=x, y=y,z=z, col sep=comma]{sites8mp3mm6qtot.csv};
\end{axis}
\end{tikzpicture}
\caption{..}
\end{subfigure}
\hfill
\begin{subfigure}[b]{.44\textwidth}
\begin{tikzpicture}\centering
\begin{axis}[colormap/hot, width =\textwidth, height=5cm, xlabel={$\theta/\pi$}, ylabel={$m\cdot g$},
legend pos = north west, colorbar, view={0}{90}]
\addplot3[contour lua, contour filled]
table [x=x, y=y,z=z, col sep=comma]{sites8mp3mm6qtot.csv};
\end{axis}
\end{tikzpicture}
\caption{..}
\end{subfigure}
\hfill
\begin{subfigure}[b]{.44\textwidth}
\begin{tikzpicture}\centering
\begin{axis}[colormap/hot, width =\textwidth, height=5cm, xlabel={$\theta/\pi$}, ylabel={$m\cdot g$},
legend pos = north west, colorbar, view={0}{90}]
\addplot3[contour lua, contour filled]
table [x=x, y=y,z=z, col sep=comma]{sites8mp3mm6qtot.csv};
\end{axis}
\end{tikzpicture}
\caption{..}
\end{subfigure}
\caption{..}
\label{}
\end{figure}
\end{document}
答案1
添加级别和point meta min/max
:
\addplot3[contour lua, contour filled={levels = {-1.05, -0.95, -0.75, -0.5,-0.25, -0.05, 0.05,0.25, 0.5,0.75, 0.95, 1.05}}, point meta min = -1.05, point meta max = 1.05]