我正在使用.cls
IEEE 的 IEEEtran,可在此处获取http://www.ieee.org/conferences_events/conferences/publishing/templates.html;所有文档都分为两列。
我正在使用pgfplots
图形进行绘图,但它只使用一列,而我希望它占据所有两列。
该图的示例代码为:
\documentclass[conference]{IEEEtran}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{booktabs}
\usepackage{amssymb}
\usepackage{array}
\usepackage{subfigure}
\usepackage[english]{babel}
\usepackage{float}
\usepackage{multirow}
\usepackage{graphicx}
\usepackage{icomma}
\usepackage{tikz}
\usepackage{pgfplots}
\newcounter{groupcount}
\pgfplotsset{
draw group line/.style n args={5}{
after end axis/.append code={
\setcounter{groupcount}{0}
\pgfplotstableforeachcolumnelement{#1}\of\datatable\as\cell{%
\def\temp{#2}
\ifx\temp\cell
\ifnum\thegroupcount=0
\stepcounter{groupcount}
\pgfplotstablegetelem{\pgfplotstablerow}{[index]0}\of\datatable
\coordinate [yshift=#4] (startgroup) at (axis cs:\pgfplotsretval,0);
\else
\pgfplotstablegetelem{\pgfplotstablerow}{[index]0}\of\datatable
\coordinate [yshift=#4] (endgroup) at (axis cs:\pgfplotsretval,0);
\fi
\else
\ifnum\thegroupcount=1
\setcounter{groupcount}{0}
\draw [
shorten >=-#5,
shorten <=-#5
] (startgroup) -- node [anchor=north] {#3} (endgroup);
\fi
\fi
}
\ifnum\thegroupcount=1
\setcounter{groupcount}{0}
\draw [
shorten >=-#5,
shorten <=-#5
] (startgroup) -- node [anchor=north] {#3} (endgroup);
\fi
}
}
}
\pgfplotstableread{
%Res. Number Res A. Res.B Group
1 0.5 4.224 1
2 0.6 4.124 1
3 0.7 4.067 1
4 0.8 4.88 1
5 0.9 4.391 1
6 1 4.273 1
7 1.1 5.506 2
8 1.2 5.391 2
9 1.3 5.52 2
10 1.4 5.418 2
11 1.5 5.285 2
12 1.6 5.194 2
13 0.5 6.224 3
14 0.6 6.124 3
15 .7 6.067 3
16 0.8 6.88 3
17 0.9 6.391 3
18 1 6.273 3
19 1.1 8.506 4
20 1.2 8.391 4
21 1.3 8.52 4
22 1.4 8.418 4
23 1.5 8.285 4
24 1.6 8.194 4
}\sindezoito
\ifCLASSINFOpdf
\else
\fi
\hyphenation{op-tical net-works semi-conduc-tor}
\begin{document}
\begin{figure}[b!]
\begin{tikzpicture}
\begin{axis}[ybar stacked, compat=newest, %Better label placement
enlarge y limits=false,
ymin=0,
enlarge x limits = .1,
bar width=12pt,
legend style={at={(0.5,-0.15)},anchor=north,legend columns=0},
x tick label style={rotate=45,anchor=east},
ylabel={Power $(mW)$},
xtick=data,
nodes near coords=\rotatebox{90}{\pgfmathprintnumber\pgfplotspointmeta},
axis lines*=left,
y axis line style={opacity=0},
yticklabels={\empty},
ytick style={draw=none},
cycle list={
{fill=black!60,draw=black!60},
{fill=black!40,draw=black!40},
{fill=black!20,draw=black!20}
},
axis on top,
major grid style=white,
ymajorgrids,
xticklabels = {BS,BS-A,HP,HP-A,LP,LP-A,BP,BP-A,HP,HP-A,LP,LP-A,
BS,BS-A,HP,HP-A,LP,LP-A,BP,BP-A,HP,HP-A,LP,LP-A},
legend style={
font=\footnotesize,
cells={anchor=west},
legend columns=5,
at={(0.5,-0.2)},
anchor=north,
/tikz/every even column/.append style={column sep=0.2cm}
},
% draw group line={[index]3}{1}{30c - 180}{-3.5ex}{7pt},
% draw group line={[index]3}{2}{50c - 180}{-3.5ex}{7pt},
% draw group line={[index]3}{1}{30c - 350}{-3.5ex}{7pt},
% draw group line={[index]3}{2}{50c - 350}{-3.5ex}{7pt},
]
\addplot table[x index=0,y index=1] \sindezoito;
\addplot table[x index=0,y index=2] \sindezoito;
\legend{Switching, Internal Cell}
\end{axis}
\end{tikzpicture}
\caption{Power results examples forum.}
\label{fig:0.18.sin}
\end{figure}
\end{document}
我尝试使用:
\begin{figure*}
\end{figure*}
但它不起作用。有人能帮我吗?
答案1
您使用的是[b!]
说明符,但没有任何文本,因此肯定会发生奇怪的事情。另外,下次请截断示例以隔离问题,您不使用这里的许多包。
您需要使用带星号的版本的图形环境,否则它会强制图形位于位置说明符有意义的列之一上。否则我建议不要管它。您可以在如何影响 LaTeX 中图形和表格等浮动环境的位置?获得有关加星标版本的更多信息。
\documentclass[conference]{IEEEtran}
\usepackage{lipsum} %<-- For dummy text
\usepackage{pgfplots}
\pgfplotsset{compat=1.7}
\newcounter{groupcount}
\pgfplotsset{
draw group line/.style n args={5}{
after end axis/.append code={
\setcounter{groupcount}{0}
\pgfplotstableforeachcolumnelement{#1}\of\datatable\as\cell{%
\def\temp{#2}
\ifx\temp\cell
\ifnum\thegroupcount=0
\stepcounter{groupcount}
\pgfplotstablegetelem{\pgfplotstablerow}{[index]0}\of\datatable
\coordinate [yshift=#4] (startgroup) at (axis cs:\pgfplotsretval,0);
\else
\pgfplotstablegetelem{\pgfplotstablerow}{[index]0}\of\datatable
\coordinate [yshift=#4] (endgroup) at (axis cs:\pgfplotsretval,0);
\fi
\else
\ifnum\thegroupcount=1
\setcounter{groupcount}{0}
\draw [
shorten >=-#5,
shorten <=-#5
] (startgroup) -- node [anchor=north] {#3} (endgroup);
\fi
\fi
}
\ifnum\thegroupcount=1
\setcounter{groupcount}{0}
\draw [
shorten >=-#5,
shorten <=-#5
] (startgroup) -- node [anchor=north] {#3} (endgroup);
\fi
}
}
}
\pgfplotstableread{
%Res. Number Res A. Res.B Group
1 0.5 4.224 1
2 0.6 4.124 1
3 0.7 4.067 1
4 0.8 4.88 1
5 0.9 4.391 1
6 1 4.273 1
7 1.1 5.506 2
8 1.2 5.391 2
9 1.3 5.52 2
10 1.4 5.418 2
11 1.5 5.285 2
12 1.6 5.194 2
13 0.5 6.224 3
14 0.6 6.124 3
15 .7 6.067 3
16 0.8 6.88 3
17 0.9 6.391 3
18 1 6.273 3
19 1.1 8.506 4
20 1.2 8.391 4
21 1.3 8.52 4
22 1.4 8.418 4
23 1.5 8.285 4
24 1.6 8.194 4
}\sindezoito
\title{Some article title}
\author{The Author}
\begin{document}
\maketitle
\begin{abstract}
\lipsum[2]
\end{abstract}
\lipsum[1-6]
\begin{figure*}\centering
\begin{tikzpicture}
\begin{axis}[ybar stacked, compat=newest, %Better label placement
enlarge y limits=false,
ymin=0,
enlarge x limits = .1,
bar width=12pt,
legend style={at={(0.5,-0.15)},anchor=north,legend columns=0},
x tick label style={rotate=45,anchor=east},
ylabel={Power $(mW)$},
xtick=data,
nodes near coords=\rotatebox{90}{\pgfmathprintnumber\pgfplotspointmeta},
axis lines*=left,
y axis line style={opacity=0},
yticklabels={\empty},
ytick style={draw=none},
cycle list={
{fill=black!60,draw=black!60},
{fill=black!40,draw=black!40},
{fill=black!20,draw=black!20}
},
axis on top,
major grid style=white,
ymajorgrids,
xticklabels = {BS,BS-A,HP,HP-A,LP,LP-A,BP,BP-A,HP,HP-A,LP,LP-A,
BS,BS-A,HP,HP-A,LP,LP-A,BP,BP-A,HP,HP-A,LP,LP-A},
legend style={
font=\footnotesize,
cells={anchor=west},
legend columns=5,
at={(0.5,-0.2)},
anchor=north,
/tikz/every even column/.append style={column sep=0.2cm}
},
% draw group line={[index]3}{1}{30c - 180}{-3.5ex}{7pt},
% draw group line={[index]3}{2}{50c - 180}{-3.5ex}{7pt},
% draw group line={[index]3}{1}{30c - 350}{-3.5ex}{7pt},
% draw group line={[index]3}{2}{50c - 350}{-3.5ex}{7pt},
]
\addplot table[x index=0,y index=1] \sindezoito;
\addplot table[x index=0,y index=2] \sindezoito;
\legend{Switching, Internal Cell}
\end{axis}
\end{tikzpicture}
\caption{Power results examples forum.}
\label{fig:0.18.sin}
\end{figure*}
\lipsum[1-6]
\end{document}