我有 4 张 tikzpicture,我想将它们并排放在一页宽度内。但它们相互重叠。你能帮我解决这个问题吗?
\documentclass[conference]{IEEEtran}
\usepackage{amsmath}
\usepackage{balance}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{algorithmic}
\usepackage[linesnumbered,ruled]{algorithm2e}
\usepackage{booktabs}
\usepackage{caption,subcaption,tikz}
\usetikzlibrary{positioning}
\usepackage{pgfplots}
\usepackage{multirow}
\usepackage{pgfplotstable}
\renewcommand*{\familydefault}{\sfdefault}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{width=7cm,compat=1.3}
\newcommand\fnote[1]{\captionsetup{font=small}\caption*{#1}}[![enter image description here][1]][1]
\begin{document}
\begin{figure*}
\centering
\begin{subfigure}[b]{0.1\textwidth}
\begin{tikzpicture}[scale=0.50]
\centering
\begin{axis}[
ybar, axis on top,
title={Calculation},
height=8cm, width=15.5cm,
bar width=0.4cm,
ymajorgrids, tick align=inside,
major grid style={draw=white},
enlarge y limits={value=.1,upper},
ymin=0, ymax=100,
axis x line*=bottom,
axis y line*=left,
y axis line style={opacity=0},
tickwidth=0pt,
enlarge x limits=true,
legend style={
at={(0.5,-0.2)},
anchor=north,
legend columns=-1,
/tikz/every even column/.append style={column sep=0.5cm}
},
ylabel={Percentage (\%)},
symbolic x coords={
0.15,0.2,0.25,0.3,
0.4,0.5,0.6,0.8,1.0},
xtick=data,
xlabel={year 2016},
nodes near coords={
\pgfmathprintnumber[precision=0]{\pgfplotspointmeta}}]
\addplot [draw=none, fill=black!60] coordinates {
(0.15, 81.2)
(0.2, 77.7)
(0.25, 79.5)
(0.3, 78.8)
(0.4, 81.4)
(0.5, 81.7)
(0.6, 82.6)
(0.8, 7.0)
(1.0, 83.9)
};
\legend{First Fix, Second Fix}
\end{axis}
\end{tikzpicture}
\end{subfigure}
\begin{subfigure}[b]{0.1\textwidth}
\begin{tikzpicture}[scale=0.50]
\centering
\begin{axis}[
ybar, axis on top,
title={Calculation},
height=8cm, width=15.5cm,
bar width=0.4cm,
ymajorgrids, tick align=inside,
major grid style={draw=white},
enlarge y limits={value=.1,upper},
ymin=0, ymax=100,
axis x line*=bottom,
axis y line*=left,
y axis line style={opacity=0},
tickwidth=0pt,
enlarge x limits=true,
legend style={
at={(0.5,-0.2)},
anchor=north,
legend columns=-1,
/tikz/every even column/.append style={column sep=0.5cm}
},
ylabel={Percentage (\%)},
symbolic x coords={
0.25,0.3,0.4,0.5,
0.6,0.8,1.0,1.2},
xtick=data,
xlabel={year 2013},
nodes near coords={
\pgfmathprintnumber[precision=0]{\pgfplotspointmeta}}]
\addplot [draw=none, fill=black!60] coordinates {
(0.25, 85.7)
(0.3, 56.1)
(0.4, 21.9)
(0.5, 30.9)
(0.6, 62.73)
(0.8, 80.69)
(1.0, 22.55)
(1.2, 30.84)
};
\legend{First Fix, Second Fix}
\end{axis}
\end{tikzpicture}
\end{subfigure}
\begin{subfigure}[b]{0.1\textwidth}
\begin{tikzpicture}[scale=0.50]
\centering
\begin{axis}[
ybar, axis on top,
title={Rate},
height=8cm, width=15.5cm,
bar width=0.4cm,
ymajorgrids, tick align=inside,
major grid style={draw=white},
enlarge y limits={value=.1,upper},
ymin=0, ymax=100,
axis x line*=bottom,
axis y line*=left,
y axis line style={opacity=0},
tickwidth=0pt,
enlarge x limits=true,
legend style={
at={(0.5,-0.2)},
anchor=north,
legend columns=-1,
/tikz/every even column/.append style={column sep=0.5cm}
},
ylabel={Percentage (\%)},
symbolic x coords={
0.3,0.4,0.5,0.6,
0.8,1.0,1.2, 1.6},
xtick=data,
xlabel={Rate},
nodes near coords={
\pgfmathprintnumber[precision=0]{\pgfplotspointmeta}}]
\addplot [draw=none, fill=black!60] coordinates {
(0.3, 59.29)
(0.4, 34.29)
(0.5, 23.15)
(0.6, 86.83)
(0.8, 75.53)
(1.0, 66.95)
(1.2, 59.37)
(1.6, 47.68)
};
\legend{First Fix, Second Fix}
\end{axis}
\end{tikzpicture}
\end{subfigure}
\begin{subfigure}[b]{0.1\textwidth}
\begin{tikzpicture}[scale=0.50]
\centering
\begin{axis}[
ybar, axis on top,
title={Calculation},
height=8cm, width=15.5cm,
bar width=0.4cm,
ymajorgrids, tick align=inside,
major grid style={draw=white},
enlarge y limits={value=.1,upper},
ymin=0, ymax=100,
axis x line*=bottom,
axis y line*=left,
y axis line style={opacity=0},
tickwidth=0pt,
enlarge x limits=true,
legend style={
at={(0.5,-0.2)},
anchor=north,
legend columns=-1,
/tikz/every even column/.append style={column sep=0.5cm}
},
ylabel={Percentage (\%)},
symbolic x coords={
0.4,0.5,0.6,
0.8,1.0,1.2, 1.6},
xtick=data,
xlabel={year 2016},
nodes near coords={
\pgfmathprintnumber[precision=0]{\pgfplotspointmeta}}]
\addplot [draw=none, fill=black!60] coordinates {
(0.4, 23.54)
(0.5, 36.05)
(0.6, 73.67)
(0.8, 43.0)
(1.0, 95.35)
(1.2, 34.30)
(1.6, 27.60)
};
\legend{First Fix, Second Fix}
\end{axis}
\end{tikzpicture}
\end{subfigure}
\caption{Rate}
\end{figure*}
\end{document}
答案1
虽然扎科为此付出了更多努力,但他却留下了一些无用的子人物。
\documentclass[conference]{IEEEtran}
\usepackage{amsmath}
\usepackage{balance}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{algorithmic}
\usepackage[linesnumbered,ruled]{algorithm2e}
\usepackage{booktabs}
\usepackage{caption,subcaption,tikz}
\usetikzlibrary{positioning}
\usepackage{pgfplots}
\usepackage{multirow}
\usepackage{pgfplotstable}
\renewcommand*{\familydefault}{\sfdefault}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{width=7cm,compat=1.3}
\newcommand\fnote[1]{\captionsetup{font=small}\caption*{#1}}%
\usepackage{showframe}% debugging tool
\begin{document}
\begin{figure*}
\centering
\begin{tikzpicture}[scale=0.50]
\centering
\begin{axis}[
ybar, axis on top,
title={Calculation},
height=8cm, width={0.5\textwidth},
bar width=0.4cm,
ymajorgrids, tick align=inside,
major grid style={draw=white},
enlarge y limits={value=.1,upper},
ymin=0, ymax=100,
axis x line*=bottom,
axis y line*=left,
y axis line style={opacity=0},
tickwidth=0pt,
enlarge x limits=true,
legend style={
at={(0.5,-0.2)},
anchor=north,
legend columns=-1,
/tikz/every even column/.append style={column sep=0.5cm}
},
ylabel={Percentage (\%)},
symbolic x coords={
0.15,0.2,0.25,0.3,
0.4,0.5,0.6,0.8,1.0},
xtick=data,
xlabel={year 2016},
nodes near coords={
\pgfmathprintnumber[precision=0]{\pgfplotspointmeta}}]
\addplot [draw=none, fill=black!60] coordinates {
(0.15, 81.2)
(0.2, 77.7)
(0.25, 79.5)
(0.3, 78.8)
(0.4, 81.4)
(0.5, 81.7)
(0.6, 82.6)
(0.8, 7.0)
(1.0, 83.9)
};
\legend{First Fix, Second Fix}
\end{axis}
\end{tikzpicture}
%
\begin{tikzpicture}[scale=0.50]
\centering
\begin{axis}[
ybar, axis on top,
title={Calculation},
height=8cm, width={0.5\textwidth},
bar width=0.4cm,
ymajorgrids, tick align=inside,
major grid style={draw=white},
enlarge y limits={value=.1,upper},
ymin=0, ymax=100,
axis x line*=bottom,
axis y line*=left,
y axis line style={opacity=0},
tickwidth=0pt,
enlarge x limits=true,
legend style={
at={(0.5,-0.2)},
anchor=north,
legend columns=-1,
/tikz/every even column/.append style={column sep=0.5cm}
},
ylabel={Percentage (\%)},
symbolic x coords={
0.25,0.3,0.4,0.5,
0.6,0.8,1.0,1.2},
xtick=data,
xlabel={year 2013},
nodes near coords={
\pgfmathprintnumber[precision=0]{\pgfplotspointmeta}}]
\addplot [draw=none, fill=black!60] coordinates {
(0.25, 85.7)
(0.3, 56.1)
(0.4, 21.9)
(0.5, 30.9)
(0.6, 62.73)
(0.8, 80.69)
(1.0, 22.55)
(1.2, 30.84)
};
\legend{First Fix, Second Fix}
\end{axis}
\end{tikzpicture}
%
\begin{tikzpicture}[scale=0.50]
\centering
\begin{axis}[
ybar, axis on top,
title={Rate},
height=8cm, width={0.5\textwidth},
bar width=0.4cm,
ymajorgrids, tick align=inside,
major grid style={draw=white},
enlarge y limits={value=.1,upper},
ymin=0, ymax=100,
axis x line*=bottom,
axis y line*=left,
y axis line style={opacity=0},
tickwidth=0pt,
enlarge x limits=true,
legend style={
at={(0.5,-0.2)},
anchor=north,
legend columns=-1,
/tikz/every even column/.append style={column sep=0.5cm}
},
ylabel={Percentage (\%)},
symbolic x coords={
0.3,0.4,0.5,0.6,
0.8,1.0,1.2, 1.6},
xtick=data,
xlabel={Rate},
nodes near coords={
\pgfmathprintnumber[precision=0]{\pgfplotspointmeta}}]
\addplot [draw=none, fill=black!60] coordinates {
(0.3, 59.29)
(0.4, 34.29)
(0.5, 23.15)
(0.6, 86.83)
(0.8, 75.53)
(1.0, 66.95)
(1.2, 59.37)
(1.6, 47.68)
};
\legend{First Fix, Second Fix}
\end{axis}
\end{tikzpicture}
%
\begin{tikzpicture}[scale=0.50]
\centering
\begin{axis}[
ybar, axis on top,
title={Calculation},
height=8cm, width={0.5\textwidth},
bar width=0.4cm,
ymajorgrids, tick align=inside,
major grid style={draw=white},
enlarge y limits={value=.1,upper},
ymin=0, ymax=100,
axis x line*=bottom,
axis y line*=left,
y axis line style={opacity=0},
tickwidth=0pt,
enlarge x limits=true,
legend style={
at={(0.5,-0.2)},
anchor=north,
legend columns=-1,
/tikz/every even column/.append style={column sep=0.5cm}
},
ylabel={Percentage (\%)},
symbolic x coords={
0.4,0.5,0.6,
0.8,1.0,1.2, 1.6},
xtick=data,
xlabel={year 2016},
nodes near coords={
\pgfmathprintnumber[precision=0]{\pgfplotspointmeta}}]
\addplot [draw=none, fill=black!60] coordinates {
(0.4, 23.54)
(0.5, 36.05)
(0.6, 73.67)
(0.8, 43.0)
(1.0, 95.35)
(1.2, 34.30)
(1.6, 27.60)
};
\legend{First Fix, Second Fix}
\end{axis}
\end{tikzpicture}
%
\caption{Rate}
\end{figure*}
\end{document}
答案2
变化:
- 子图形的宽度(其宽度必须大于其内容的宽度)
ylabel
只有第一个图- 将比例增加到 0.6
- 图像宽度减小至 80 毫米(缩放前)
- 旋转
xtick label
- 此图
axis
收集了常用选项pgfplotsset
\documentclass[conference]{IEEEtran}
\usepackage{amsmath}
%\usepackage{balance}
\usepackage{amsfonts}
\usepackage{amssymb}
%\usepackage{algorithmic}
%\usepackage[linesnumbered,ruled]{algorithm2e}
\usepackage{booktabs, multirow}
\usepackage{caption, subcaption}
\usepackage{pgfplotstable}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usepackage{pgfplots}
\pgfplotsset{width=7cm,compat=1.3}
\newcommand\fnote[1]{\captionsetup{font=small}\caption*{#1}}
\renewcommand*{\familydefault}{\sfdefault}
\begin{document}
\begin{figure*}
\pgfplotsset{% for this figure
width=80mm,
ybar, axis on top,
ymajorgrids, tick align=inside,
major grid style={draw=white},
enlarge y limits={value=.1,upper},
ymin=0, ymax=100,
axis x line*=bottom,
axis y line*=left,
y axis line style={opacity=0},
xtick=data,
xticklabel style={rotate=90,
anchor=east},
tickwidth=0pt,
enlarge x limits=true,
xlabel style={at={(0.5,-0.18)},
anchor=north},
legend style={
at={(0.5,-0.3)},
anchor=north,
legend columns=-1,
/tikz/every even column/.append style={column sep=0.5cm}
},
nodes near coords={
\pgfmathprintnumber[precision=0]{\pgfplotspointmeta}}
}% end of common pgflotsset
\centering
\begin{subfigure}[b]{0.26\textwidth}
\begin{tikzpicture}[scale=0.6]
\begin{axis}[
title={Calculation},
symbolic x coords={
0.15, 0.2, 0.25,0.3,
0.4,0.5,0.6,0.8,1.0},
bar width=0.4cm,
ylabel={Percentage (\%)},
xlabel={year 2016},
]
\addplot [draw=none, fill=black!60] coordinates {
(0.15, 81.2)
(0.2, 77.7)
(0.25, 79.5)
(0.3, 78.8)
(0.4, 81.4)
(0.5, 81.7)
(0.6, 82.6)
(0.8, 7.0)
(1.0, 83.9)
};
\legend{First Fix, Second Fix}
\end{axis}
\end{tikzpicture}
\end{subfigure}
\begin{subfigure}[b]{0.24\textwidth}
\begin{tikzpicture}[scale=0.6]
\begin{axis}[
title={Calculation},
bar width=0.4cm,
symbolic x coords={
0.25,0.3,0.4,0.5,
0.6,0.8,1.0,1.2},
xlabel={year 2013},
]
\addplot [draw=none, fill=black!60] coordinates {
(0.25, 85.7)
(0.3, 56.1)
(0.4, 21.9)
(0.5, 30.9)
(0.6, 62.73)
(0.8, 80.69)
(1.0, 22.55)
(1.2, 30.84)
};
\legend{First Fix, Second Fix}
\end{axis}
\end{tikzpicture}
\end{subfigure}
\begin{subfigure}[b]{0.24\textwidth}
\begin{tikzpicture}[scale=0.6]
\begin{axis}[
title={Rate},
bar width=0.4cm,
symbolic x coords={
0.3,0.4,0.5,0.6,
0.8,1.0,1.2, 1.6},
xlabel={Rate},
]
\addplot [draw=none, fill=black!60] coordinates {
(0.3, 59.29)
(0.4, 34.29)
(0.5, 23.15)
(0.6, 86.83)
(0.8, 75.53)
(1.0, 66.95)
(1.2, 59.37)
(1.6, 47.68)
};
\legend{First Fix, Second Fix}
\end{axis}
\end{tikzpicture}
\end{subfigure}
\begin{subfigure}[b]{0.24\textwidth}
\begin{tikzpicture}[scale=0.6]
\begin{axis}[
title={Calculation},
bar width=0.4cm,
symbolic x coords={
0.4,0.5,0.6,
0.8,1.0,1.2, 1.6},
xlabel={year 2016},
]
\addplot [draw=none, fill=black!60] coordinates {
(0.4, 23.54)
(0.5, 36.05)
(0.6, 73.67)
(0.8, 43.0)
(1.0, 95.35)
(1.2, 34.30)
(1.6, 27.60)
};
\legend{First Fix, Second Fix}
\end{axis}
\end{tikzpicture}
\end{subfigure}
\caption{Rate}
\end{figure*}
\end{document}
笔记:
- 我评论了包,但我还没有
- 图像非常小,我建议考虑只有两个,而不是按行缩放
- 不清楚你为什么使用 环境。如果在put
subfigure
之间省略它们,则会获得相同的结果tikzpictures
\hfill