为什么我的颜色条在 pgfplots 中的 groupplot 环境中变得混乱?

为什么我的颜色条在 pgfplots 中的 groupplot 环境中变得混乱?

我有一个如下所示的彩色条形图: 在此处输入图片描述

一旦我使用groupplot刻度添加类似的图形,颜色条的刻度标签就会消失: 在此处输入图片描述

有人知道如何修复这个问题吗?下面是groupplot我正在使用的完整代码:


\usepackage{pgfplots}
\usepackage{pgfplotstable}%fitting functions
\usepackage{tikz}
\usepackage{xcolor}
\usetikzlibrary{tikzmark}
\usepackage{pgfplotstable}
\usepgfplotslibrary{fillbetween}
\usetikzlibrary{tikzmark,patterns}
\usepgfplotslibrary{groupplots}


\pgfkeys{/pgf/number format/.cd,1000 sep={}}



\pgfplotsset{compat=1.15}
\pgfplotsset{label style={font=\Large},
            tick label style={font=\Large}}


\begin{document}

\begin{tikzpicture}

%%%%%%%% left channel

\begin{groupplot}[group style={group size=1 by 3,
    vertical sep=7em},
%   axis x line=bottom,
%   axis y line=center,
    width=10cm,
    height=7cm,
    ticks=none,
    axis line style={draw=none},
    xmin=-35,xmax=35,
    ymin=-2,ymax=47,
]

\nextgroupplot[
    declare function={k(\x)=max(-12.5,min(-8,-4.5*\x/20.45-6.53));
    l(\x)=max(-14,min(-10,-4*\x/20.45-8.69));},
    declare function={f(\x)=max(8,min(12.5,4.5*\x/20.45+6.53));
    g(\x)=max(10,min(14,4*\x/20.45+8.69));},
    view={0}{90},
    colorbar,
    colormap={whiteblue}{
        color(0cm)=(green!10); color(1cm)=(green)},
    colorbar style={
        ylabel={channel width [mm]},
        yticklabel={$\pgfmathparse{-1*\tick}%
        \pgfmathprintnumber\pgfmathresult$}}
]
%%%%%left

\begin{scope}  
\clip[variable=\x] plot[samples at={-0.2,6.7,27.15,37.3}] ({k(\x)},\x) -- plot[samples at={37.3,27.15,6.7,-0.2}] ({l(\x)},\x) -- cycle;
\addplot3[surf,shader=flat,point meta={l(y)-k(y)},domain=-15:-5,
    domain y=-1:40] {x};
\end{scope}

%%%%%right

\begin{scope}  
\clip[variable=\x] plot[samples at={-0.2,6.7,27.15,37.3}] ({f(\x)},\x) -- plot[samples at={37.3,27.15,6.7,-0.2}] ({g(\x)},\x) -- cycle;
\addplot3[surf,shader=flat,point meta={f(y)-g(y)},domain=5:15,
    domain y=-1:40] {x};
\end{scope}


\nextgroupplot[
    declare function={a(\x)=max(-13.5,min(-8,-5.5*\x/20.45-6.2));
    b(\x)=max(-14,min(-10,-4*\x/20.45-8.69));},
    declare function={c(\x)=max(8,min(13.5,5.5*\x/20.45+6.2));
    d(\x)=max(10,min(14,4*\x/20.45+8.69));},
    view={0}{90},
    colorbar,
    colormap={whiteblue}{
        color(0cm)=(blue!10); color(1cm)=(blue)},
    colorbar style={
        ylabel={channel width [mm]},
        yticklabel={$\pgfmathparse{-1*\tick}%
        \pgfmathprintnumber\pgfmathresult$}}
]

\begin{scope}  
\clip[variable=\x] plot[samples at={-0.2,6.7,27.15,37.3}] ({a(\x)},\x) -- plot[samples at={37.3,27.15,6.7,-0.2}] ({b(\x)},\x) -- cycle;
\addplot3[surf,shader=flat,point meta={b(y)-a(y)},domain=-15:-5,
    domain y=-1:40] {x};
\end{scope}


\begin{scope}  
\clip[variable=\x] plot[samples at={-0.2,6.7,27.15,37.3}] ({c(\x)},\x) -- plot[samples at={37.3,27.15,6.7,-0.2}] ({d(\x)},\x) -- cycle;
\addplot3[surf,shader=flat,point meta={c(y)-d(y)},domain=5:15,
    domain y=-1:40] {x};
\end{scope}



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

答案1

您可以在组图选项中设置ticks=none。假设您只想要颜色条的刻度,您可以使用它们在那里安装ticks=major

\documentclass[tikz,border=3mm]{standalone}
\usepackage{pgfplots}
\usepgfplotslibrary{groupplots}


\pgfkeys{/pgf/number format/.cd,1000 sep={}}



\pgfplotsset{compat=1.15}
\pgfplotsset{label style={font=\Large},
            tick label style={font=\Large}}



\begin{document}

\begin{tikzpicture}

%%%%%%%% left channel

\begin{groupplot}[group style={group size=1 by 2,
    vertical sep=7em},
%   axis x line=bottom,
%   axis y line=center,
    width=10cm,
    height=7cm,
    ticks=none,
    axis line style={draw=none},
    xmin=-35,xmax=35,
    ymin=-2,ymax=47,
]

\nextgroupplot[
    declare function={k(\x)=max(-12.5,min(-8,-4.5*\x/20.45-6.53));
    l(\x)=max(-14,min(-10,-4*\x/20.45-8.69));},
    declare function={f(\x)=max(8,min(12.5,4.5*\x/20.45+6.53));
    g(\x)=max(10,min(14,4*\x/20.45+8.69));},
    view={0}{90},
    colorbar,
    colormap={whiteblue}{
        color(0cm)=(green!10); color(1cm)=(green)},
    colorbar style={ticks=major,
        ylabel={channel width [mm]},
        yticklabel={$\pgfmathparse{-1*\tick}%
        \pgfmathprintnumber\pgfmathresult$}}
]
%%%%%left

\begin{scope}  
\clip[variable=\x] plot[samples at={-0.2,6.7,27.15,37.3}] ({k(\x)},\x) -- plot[samples at={37.3,27.15,6.7,-0.2}] ({l(\x)},\x) -- cycle;
\addplot3[surf,shader=flat,point meta={l(y)-k(y)},domain=-15:-5,
    domain y=-1:40] {x};
\end{scope}

%%%%%right

\begin{scope}  
\clip[variable=\x] plot[samples at={-0.2,6.7,27.15,37.3}] ({f(\x)},\x) -- plot[samples at={37.3,27.15,6.7,-0.2}] ({g(\x)},\x) -- cycle;
\addplot3[surf,shader=flat,point meta={f(y)-g(y)},domain=5:15,
    domain y=-1:40] {x};
\end{scope}


\nextgroupplot[
    declare function={a(\x)=max(-13.5,min(-8,-5.5*\x/20.45-6.2));
    b(\x)=max(-14,min(-10,-4*\x/20.45-8.69));},
    declare function={c(\x)=max(8,min(13.5,5.5*\x/20.45+6.2));
    d(\x)=max(10,min(14,4*\x/20.45+8.69));},
    view={0}{90},
    colorbar,
    colormap={whiteblue}{
        color(0cm)=(blue!10); color(1cm)=(blue)},
    colorbar style={ticks=major,
        ylabel={channel width [mm]},
        yticklabel={$\pgfmathparse{-1*\tick}%
        \pgfmathprintnumber\pgfmathresult$}}
]

\begin{scope}  
\clip[variable=\x] plot[samples at={-0.2,6.7,27.15,37.3}] ({a(\x)},\x) -- plot[samples at={37.3,27.15,6.7,-0.2}] ({b(\x)},\x) -- cycle;
\addplot3[surf,shader=flat,point meta={b(y)-a(y)},domain=-15:-5,
    domain y=-1:40] {x};
\end{scope}


\begin{scope}  
\clip[variable=\x] plot[samples at={-0.2,6.7,27.15,37.3}] ({c(\x)},\x) -- plot[samples at={37.3,27.15,6.7,-0.2}] ({d(\x)},\x) -- cycle;
\addplot3[surf,shader=flat,point meta={c(y)-d(y)},domain=5:15,
    domain y=-1:40] {x};
\end{scope}



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

在此处输入图片描述

如果您希望到处都有蜱虫,请放下ticks=none

相关内容