使用颜色条和组图时绘图对齐错误

使用颜色条和组图时绘图对齐错误

当我使用颜色条时,绘图的对齐方式不正确,如图所示。我该如何修复此问题?

此外,我想知道如何才能使小轴刻度变为黑色而不是灰色?现在除了右下角的图外,您无法在所有图中看到它们。

|____|____|____|
0   500  1000 1500

在此处输入图片描述

\begin{tikzpicture}

\pgfplotsset{%
  width=4cm,
  height=4cm,
  scale only axis,
  every x tick label/.append style={font=\scriptsize\color{gray!80!black}},
  xmajorgrids,
  xminorgrids,
  every y tick label/.append style={font=\scriptsize\color{gray!80!black}},
  ymajorgrids,
  yminorgrids
}

\begin{groupplot}[
  group style={group size=2 by 2},
  y dir=reverse,
  axis on top
]

\nextgroupplot[
  xmin=0, xmax=1805,
  xticklabels={\empty},
  ymin=0, ymax=1200,
  colorbar right,
  colormap/blackwhite,
]
\addplot graphics [
  xmin=0, 
  xmax=1805, 
  ymin=0,
  ymax=1200
] {scarlett_dx.png};

\nextgroupplot[
  xmin=0, xmax=1805,
  xticklabels={\empty},
  ymin=0, ymax=1200,
  yticklabels={\empty},
  colorbar right,
  colormap/blackwhite
]
\addplot graphics [
  xmin=0, 
  xmax=1805, 
  ymin=0,
  ymax=1200
] {scarlett_ddx.png};

\nextgroupplot[
  xmin=0, xmax=1805,
  ymin=0, ymax=1200,
  colorbar right,
  colormap/blackwhite
]
\addplot graphics [
  xmin=0, 
  xmax=1805, 
  ymin=0,
  ymax=1200
] {scarlett_dy.png};

\nextgroupplot[
  xmin=0, xmax=1805,
  ymin=0, ymax=1200,
  yticklabels={\empty},
  colorbar right,
  colormap/blackwhite
]
\addplot graphics [
  xmin=0, 
  xmax=1805, 
  ymin=0,
  ymax=1200
] {scarlett_ddy.png};

\end{groupplot}

答案1

horizontal sep您可以使用 中的和vertical sep选项来调整图之间的填充group style

要调整刻度线的样式,请使用tick style=gray!50

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{pgfplots}
\usepgfplotslibrary{groupplots}

\begin{document}
\begin{tikzpicture}

\pgfplotsset{%
  width=4cm,
  height=4cm,
  scale only axis,
  every x tick label/.append style={font=\scriptsize\color{gray!80!black}},
  xmajorgrids,
  xminorgrids,
  every y tick label/.append style={font=\scriptsize\color{gray!80!black}},
  ymajorgrids,
  yminorgrids
}

\begin{groupplot}[
  group style={
    group size=2 by 2,
    horizontal sep=6em
    },
  y dir=reverse,
  axis on top,
  tick style=gray!50
]

\nextgroupplot[
  xmin=0, xmax=1805,
  xticklabels={\empty},
  ymin=0, ymax=1200,
  colorbar right,
  colormap/blackwhite,
]
\addplot graphics [
  xmin=0, 
  xmax=1805, 
  ymin=0,
  ymax=1200
] {scarlett_dx.png};

\nextgroupplot[
  xmin=0, xmax=1805,
  xticklabels={\empty},
  ymin=0, ymax=1200,
  yticklabels={\empty},
  colorbar right,
  colormap/blackwhite
]
\addplot graphics [
  xmin=0, 
  xmax=1805, 
  ymin=0,
  ymax=1200
] {scarlett_ddx.png};

\nextgroupplot[
  xmin=0, xmax=1805,
  ymin=0, ymax=1200,
  colorbar right,
  colormap/blackwhite
]
\addplot graphics [
  xmin=0, 
  xmax=1805, 
  ymin=0,
  ymax=1200
] {scarlett_dy.png};

\nextgroupplot[
  xmin=0, xmax=1805,
  ymin=0, ymax=1200,
  yticklabels={\empty},
  colorbar right,
  colormap/blackwhite
]
\addplot graphics [
  xmin=0, 
  xmax=1805, 
  ymin=0,
  ymax=1200
] {scarlett_ddy.png};

\end{groupplot}
\end{tikzpicture}
\end{document}

相关内容