由于计算限制,我正在使用另一个绘图软件创建热图,并使用选项和导入热图和颜色条graphics
。groupplot
此外,我需要yaxis
在图像顶部绘制第二个以获得有意义的刻度。
问题是,一旦我添加顶线图,对齐就会中断。
梅威瑟:
\documentclass[tikz]{standalone}
\usepackage{graphicx}
\graphicspath{{Bilder/}}
\usepackage{siunitx}
\usepackage{pgfplots}
\usepgfplotslibrary{groupplots}
\usepackage{pgfplotstable}
\pgfplotstableread{
T x
600.51 0.14
595.42 1.04
593.92 1.96
587.42 2.95
583.45 4.12
579.92 4.6
578.28 5.77
569.69 7.00
553.09 8.33
539.71 9.24
526.59 9.93
522.43 10.95
512.92 11.9
486.56 13.06
470.83 14.05
}\datah
\begin{document}
\begin{tikzpicture}
\begin{groupplot}[group style={group size=2 by 2, vertical sep=0pt}, height=0.5\textwidth]
\nextgroupplot[
scale only axis,
enlarge x limits=false,
width=0.5\textwidth,
height=0.2\textwidth,
xmin=0,
xmax=14,
xtick={0,2,...,14},
ylabel={$T_{\mathrm{max}}$ in \si{\celsius}}
]
\addplot table[x=x, y=T] {\datah};
\nextgroupplot[group/empty plot]
\nextgroupplot[
scale only axis,
enlargelimits=false,
xtick=\empty,
ytick=\empty,
width=0.5\textwidth,
]
\addplot graphics[xmin=0, xmax=1784, ymin=0, ymax=1676]{heatmap.png};
\nextgroupplot[
scale only axis,
enlargelimits=false,
xtick=\empty,
ytick=\empty,
width=0.05\textwidth
]
\addplot graphics[xmin=0, xmax=98, ymin=0, ymax=1250]{colorbar.png};
\end{groupplot}
\begin{groupplot}[group style={group size=2 by 2, vertical sep=0pt}, height=0.5\textwidth]
\nextgroupplot[group/empty plot]
\nextgroupplot[group/empty plot]
\nextgroupplot[
scale only axis,
enlargelimits=false,
xmin=0,
xmax=14,
xtick={0,2,...,14},
xlabel={$x$ in \si{\mm}},
ymin=0,
ymax=700,
y dir=reverse,
ylabel={$t$ in \si{\second}},
width=0.5\textwidth
]
\nextgroupplot[
scale only axis,
enlargelimits=false,
width=0.05\textwidth,
xtick=\empty,
ymin=20,
ymax=610,
yticklabel pos=right,
xmin=0,
xmax=1,
title={$T$ in \si{\celsius}}
]
\end{groupplot}
\end{tikzpicture}
\end{document}
答案1
这主要是您的代码,并进行了一些简化。
为了适合.png
s,headmap.png
被重新采样到与 相同的高度colormap.png
。
警告:使用此设置并使用环境 groupplots
,如果顶部图改变其高度,则颜色条的位置将被修改。请参阅下面的更新。
\documentclass[tikz]{article}
\usepackage{graphicx}
\graphicspath{{Bilder/}}
\usepackage{siunitx}
\usepackage{pgfplots}
\usepgfplotslibrary{groupplots}
\usepackage{pgfplotstable}
\pgfplotstableread{
T x
600.51 0.14
595.42 1.04
593.92 1.96
587.42 2.95
583.45 4.12
579.92 4.6
578.28 5.77
569.69 7.00
553.09 8.33
539.71 9.24
526.59 9.93
522.43 10.95
512.92 11.9
486.56 13.06
470.83 14.05
}\datah
\begin{document}
\begin{tikzpicture}
\begin{groupplot}[group style={group size=2 by 2, vertical sep=1cm, horizontal sep=-1.5cm}, height=0.3\textheight, width=0.5\textwidth]
\nextgroupplot[
scale only axis,
enlarge x limits=false,
height=0.2\textheight,
xmin=0,
xmax=14,
xtick={0,2,...,14},
ylabel={$T_{\mathrm{max}}$ in \si{\celsius}}
]
\addplot table[x=x, y=T] {\datah};
\nextgroupplot[group/empty plot ]
\nextgroupplot[
scale only axis,
enlargelimits=false,
xmin=0,
xmax=14,
xtick={0,2,...,14},
xlabel={$x$ in \si{\mm}},
ymin=0,
ymax=750,
y dir=reverse,
ylabel={$t$ in \si{\second}},
]
\addplot graphics[xmin=0, xmax=14, ymin=0, ymax=750]{heatmap.png};
\nextgroupplot[
scale only axis,
enlargelimits=false,
width=0.05\textwidth,
xtick=\empty,
ymin=0,
ymax=650,
yticklabel pos=right,
xmin=0,
xmax=1,
title={$T$ in \si{\celsius}}
]
\addplot graphics[xmin=0, xmax=1, ymin=0, ymax=650]{colorbar.png};
\end{groupplot}
\end{tikzpicture}
\end{document}
更新后续问题之后
该groupplots
环境允许您比较具有相同功能的多个图,
[⟨options⟩]
因为它们适用于整个环境中的所有图,从而节省了大量的打字工作。
在这种情况下,只需让三个图表彼此之间具有所需的对齐即可。
\documentclass{article}
\usepackage{graphicx}
\graphicspath{{Bilder/}}
\usepackage{siunitx}
\usepackage{pgfplots}
\usepgfplotslibrary{groupplots}
\usepackage{pgfplotstable}
\pgfplotstableread{
T x
600.51 0.14
595.42 1.04
593.92 1.96
587.42 2.95
583.45 4.12
579.92 4.6
578.28 5.77
569.69 7.00
553.09 8.33
539.71 9.24
526.59 9.93
522.43 10.95
512.92 11.9
486.56 13.06
470.83 14.05
}\datah
\begin{document}
\begin{tikzpicture}
\begin{axis}[name=plot1, scale only axis,
enlarge x limits=false,
height=0.15\textheight,
width=0.4\textwidth,
font=\small,
xmin=0,
xmax=15,
xtick={0,2,...,14},
ylabel={$T_{\mathrm{max}}$ in \si{\celsius}}]
\addplot table[x=x, y=T] {\datah};
\end{axis}
\begin{axis}[name=plot2,at={($(plot1.south)-(0,1cm)$)},anchor=north, % adjust separation <<<
height=0.2\textheight,
width=0.4\textwidth,
scale only axis,
enlargelimits=false,
font=\small,
xmin=0,
xmax=15,
xtick={0,2,...,14},
xlabel={$x$ in \si{\mm}},
ymin=0,
ymax=750,
y dir=reverse,
ylabel={$t$ in \si{\second}},
]
\addplot graphics[xmin=0, xmax=15, ymin=0, ymax=750]{heatmap.png};
\end{axis}
\begin{axis}[name=plot3,at={($(plot2.east)+(0.25cm,0)$)},anchor=west, % adjust separation <<<
scale only axis,
enlargelimits=false,
height=0.2\textheight,
width=0.02\textwidth,
xtick=\empty,
font=\small,
ymin=0,
ymax=650,
yticklabel pos=right,
xmin=0,
xmax=1,
%title={$T$ in \si{\celsius}}, % optional
ylabel near ticks, yticklabel pos=right,ylabel={$T$ in \si{\celsius}}
]
\addplot graphics[xmin=0, xmax=1, ymin=0, ymax=650]{colorbar.png};
\end{axis}
\end{tikzpicture}
\end{document}