有没有办法使这个情节的描述呈对角线形式,以便于阅读?
我使用的代码:
% Data
%----------------------------------------
\pgfplotstableread[row sep=\\,col sep=&]{
bench & DCPT & RPT \\
twolf & 0.99 & 1.00 \\
bzip2s & 1.00 & 1.00 \\
swim & 1.01 & 0.99 \\
bzip2g & 1.03 & 1.01 \\
bzip2p & 1.04 & 1.01 \\
art110 & 1.06 & 1.02 \\
art470 & 1.06 & 1.02 \\
apsi & 1.09 & 1.01 \\
applu & 1.09 & 1.03 \\
galgel & 1.10 & 1.02 \\
wupwise & 1.25 & 1.08 \\
ammp & 1.68 & 1.12 \\
}\mydata
% Plot
%----------------------------------------
\begin{figure}
\begin{tikzpicture}
\begin{axis}[
ybar,
bar width=.1cm,
width=\textwidth/2,
%height=.5\textwidth/1,5,
legend style={at={(0.5,1)},
anchor=north,legend columns=-1},
symbolic x coords={twolf, bzip2s, swim, bzip2g, bzip2p, art110, art470, apsi, applu, galgel, wupwise, ammp},
xtick=data,
ymin=.95,ymax=2,
ylabel={Speedup},
]
\addplot table[x=bench,y=DCPT]{\mydata};
\addplot table[x=bench,y=RPT]{\mydata};
%\addplot table[x=interval,y=carR]{\mydata};
\legend{DCPT, RPT}
\end{axis}
\end{tikzpicture}
\caption{Caption.}
\label{fig:fig}
\end{figure}
答案1
答案2
只是为了练习,稍微修改了你的设计并使用了表中的符号坐标数据\mydata
。基于 这回答:
\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}
\usepackage{pgfplotstable}
\pgfplotsset{compat=1.16}
\pgfplotstableread[row sep=\\,col sep=&]{
bench & DCPT & RPT \\
twolf & 0.99 & 1.00 \\
bzip2s & 1.00 & 1.00 \\
swim & 1.01 & 0.99 \\
bzip2g & 1.03 & 1.01 \\
bzip2p & 1.04 & 1.01 \\
art110 & 1.06 & 1.02 \\
art470 & 1.06 & 1.02 \\
apsi & 1.09 & 1.01 \\
applu & 1.09 & 1.03 \\
galgel & 1.10 & 1.02 \\
wupwise & 1.25 & 1.08 \\
ammp & 1.68 & 1.12 \\
}\mydata
\begin{document}
\begin{tikzpicture}
\begin{axis}[x=10mm,
ybar,
bar width=3.2mm,
enlarge x limits=0.1,
enlarge y limits={.1, upper},
% y ticks style and label
ylabel={Speedup},
ymin=0,
% x axis ticks and style
xtick=data,
xticklabels from table={\mydata}{bench}, % <-------------------
table/x expr = \coordindex, % <-------------------
x tick label style = {rotate=45, anchor=east},
% legends and labels
legend style = {legend columns=-1,
at={(0.5,0.98)},
anchor=north,
/tikz/every even column/.append style={column sep=1em}
},
]
\addplot [fill=blue!80!black]
table [y=DCPT] {\mydata};
\addlegendentry{DCPT};
\addplot [fill=yellow!80!black]
table [y=RPT] {\mydata};
\addlegendentry{RPT};
\end{axis}
\end{tikzpicture}
\end{document}