带子图的垂直颜色条(tikz)

带子图的垂直颜色条(tikz)

我有两个彼此相邻的子图(1x2 配置)

 \begin{figure*}[]
     \centering
     \begin{tabular}{
     @{}>{\centering\arraybackslash}m{\dimexpr.8\textwidth-\tabcolsep\relax}
  >{\centering\arraybackslash}m{\dimexpr.3\textwidth-\tabcolsep\relax}@{}
  }
     \begin{subfigure}[b]{0.38\textwidth}
         \centering
         \includegraphics[height=3.5cm,width=\textwidth]{example-image-a}
         \caption{Figure A}
         \label{fig:a}
     \end{subfigure}\hfill
     \begin{subfigure}[b]{0.38\textwidth}
         \centering
         \includegraphics[height=3.5cm,width=\textwidth]{example-image-b}
         \caption{Figure B}
         \label{fig:almles_vort}
     \end{subfigure}
&
\begin{tikzpicture}[rotate=0]
\centering
\begin{axis}[
    hide axis,
    scale only axis,
    height=0pt,
    width=0pt,
    colormap/hot2,
    colorbar horizontal,
    point meta min=0,
    point meta max=300,
    colorbar style={
        width=3.5cm,
        rotate=90,
        title=Colormap Title,
        xtick style={draw=none},
        xtick={0,100,200,300},
        xticklabel style={xshift=10pt,yshift=5pt},
        at={(-0.25,0.0)},anchor=north,   
        title style={xshift=3.5cm,yshift=3.5cm},
    }
  ]
    \addplot [draw=none] coordinates {(0,0) (1,1)};
\end{axis}
\end{tikzpicture}

\end{tabular}
        \caption{\textbf{Image}}
        \label{fig:c}
\end{figure*}

在此处输入图片描述

我想要:-

  1. 删除图像和颜色条之间的空白
  2. 将颜色条与图像对齐,使其具有与颜色条相同的高度

答案1

这是一种可能性。没有表格的话,调整三个图之间的间距会更容易。

是

\documentclass[12pt,a4paper]{article}

\usepackage{graphicx}
\usepackage[left=2.00cm, right=2.00cm, top=4.00cm, bottom=3.00cm]{geometry}
\usepackage{subcaption}
\usepackage{pgfplots}
\begin{document}
    
     \begin{figure*}[]
        \centering
            \begin{subfigure}[t]{0.38\textwidth}
                \includegraphics[height=3.5cm,width=\textwidth]{example-image-a}
                \caption{Figure A}
                \label{fig:a}
            \end{subfigure}\hspace{10pt}
            \begin{subfigure}[t]{0.38\textwidth}
                \includegraphics[height=3.5cm,width=\textwidth]{example-image-b}
                \caption{Figure B}
                \label{fig:almles_vort}
            \end{subfigure}\hspace*{-25pt} % <<<<<<<<<<<<<<< close the gap
        \begin{subfigure}[t]{0.15\textwidth}    
            \begin{tikzpicture}[rotate=0]
                \begin{axis}[
                    hide axis,
                    scale only axis,
                    height=0pt,
                    width=0pt,
                    colormap/hot2,
                    colorbar horizontal,
                    point meta min=0,
                    point meta max=300,
                    colorbar style={
                        width=3.5cm,
                        rotate=90,
                        title= Colormap Title,
                        xtick style={draw=none},
                        xtick={0,100,200,300},
                        xticklabel style={xshift=12pt,yshift=15pt},
                        at={(-0.5,0.0)},anchor=south,   
                        title style={xshift=3.5cm,yshift=4cm},
                    }
                    ]
                    \addplot [draw=none] coordinates {(0,0) (1,1)};
                \end{axis}
            \end{tikzpicture}   
            \end{subfigure}     
        \caption{\textbf{Image}}
        \label{fig:c}
    \end{figure*}       
    
\end{document}

这是另一个。

是

\documentclass[12pt,a4paper]{article}

\usepackage{graphicx}
\usepackage[left=2.00cm, right=2.00cm, top=4.00cm, bottom=3.00cm]{geometry}
\usepackage{subcaption}
\usepackage{pgfplots}
\begin{document}
    
     \begin{figure*}[]
        \centering
            \begin{subfigure}[t]{0.38\textwidth}
                \includegraphics[height=3.5cm,width=\textwidth]{example-image-a}
                \caption{Figure A}
                \label{fig:a}
            \end{subfigure}\hspace*{10pt}
            \begin{subfigure}[t]{0.38\textwidth}
                \includegraphics[height=3.5cm,width=\textwidth]{example-image-b}
                \caption{Figure B}
                \label{fig:almles_vort}
            \end{subfigure}\hspace*{-25pt} % <<<<<<<<<<<<<<< close the gap
        \begin{subfigure}[t]{0.2\textwidth}
            \centering  
            \begin{tikzpicture}[rotate=0]
                \begin{axis}[
                    hide axis,
                    scale only axis,
                    height=0pt,
                    width=0pt,
                    colormap/hot2,
                    colorbar horizontal,
                    point meta min=0,
                    point meta max=300,
                    colorbar style={
                        width=3.5cm,
                        rotate=90,
%                       title= Colormap Title,
                        xtick style={draw=none},
                        xtick={0,100,200,300},
                        xticklabel style={xshift=12pt,yshift=16pt},
                        at={(-.5,0.0)},anchor=south,   
                        title style={xshift=3.5cm,yshift=4cm},
                    }
                    ]
                    \addplot [draw=none] coordinates {(0,0) (1,1)};
                \end{axis}
            \end{tikzpicture}
            \caption*{Colormap title}   
            \end{subfigure}         
    
        \caption{\textbf{Image}}
        \label{fig:c}
    \end{figure*}       
    
\end{document}

更新

\hfill您可以在最后一个子图之前添加负空间,并将其替换为,从而尽可能地缩小白色间隙\hspace{..}

X

        \caption{Figure B}
                \label{fig:almles_vort}
            \end{subfigure}\hspace*{-25pt} % <<<<<<<<<<<<<<< close the gap
        \begin{subfigure}[t]{0.15\textwidth}    
            \begin{tikzpicture}[rotate=0]
                \begin{axis}[
                    hide axis,
                    scale only axis,

相关内容