我创建了以下图表,但我觉得它不太美观。我有一些想法,想让它看起来更好(如下图所示),但我不知道如何实现。有人可以告诉我如何进行这些修改,或者忽略我的想法,但提供一个使图表更具视觉吸引力的替代示例吗?
- 将图例中的文字左对齐,而不是居中
- 图形是正方形而非矩形,且不包含半正方形(包含正确代码 0-2)
- 线条更粗/更明显
- 图表左右延伸未超出所用 X 值的范围(从 1 开始,到 10 结束)
- Y 轴标签距离图表左侧不太远
。
\documentclass[sigconf,review, anonymous]{acmart}
\citestyle{acmauthoryear}
\usepackage{booktabs} % For formal tables
\usepackage{xcolor,colortbl,multirow,array,titlecaps}
\usepackage{graphicx}
\usepackage{tikz,pgfplots,subcaption}
% Document starts
\begin{document}
\begin{figure}
\begin{center}
\begin{subfigure}{\columnwidth}
\begin{tikzpicture}
\begin{axis}[stack plots=false,
ylabel={Correct Codes},
xlabel={Keyword Frequency (Code)},
cycle list name=color list,
grid=major,
legend style={at={(0,-.2)}, anchor=north west},
]
\addplot
coordinates {(1,5)(2,5)(3,4)(4,5)(5,5)(6,5)(7,5)(8,5)(9,5)(10,5)};
\addplot
coordinates {(1,9)(2,6)(3,6)(4,5)(5,4)(6,5)(7,6)(8,5)(9,5)(10,5)};
%% Color difference was not sufficient in default, forcing new colour
\pgfplotsset{cycle list shift=+2}
\addplot
coordinates {(1,6)(2,7)(3,7)(4,6)(5,7)(6,9)(7,10)(8,10)(9,9)(10,9)};
%% Color difference was not sufficient in default, forcing new colour
\pgfplotsset{cycle list shift=+2}
\addplot
coordinates {(1,7)(2,6)(3,5)(4,5)(5,7)(6,4)(7,4)(8,4)(9,4)(10,5)};
\legend{WordCount,KeywordRelevance,KeywordCount,DISCOKeywords}
\end{axis}
\end{tikzpicture}
\end{subfigure}
\caption{Keyword Frequency (Code)}
\label{fig:keyword-frequency}
\end{center}
\end{figure}
\end{document}
答案1
有时做事会有几种方法,mvienney 的指点很有帮助。
您是否知道PGFplots 手册,它更加有用,并且充满了示例?您询问的所有内容都包含在该文档中。
输出
代码
\documentclass[tikz]{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}
[
%stack plots=false, % not useful here.
unit vector ratio=1 1, % same size for both unit axis vectors
title={My title: Keyword Frequency (Code)}, %
title style=
{
at = {(0,0)},
anchor = north west,
yshift=-1.5cm,
font=\LARGE,
},
ylabel={Correct Codes},
ylabel style=
{
yshift=-4mm,
%you can set other attributes here if you like
%red % e.g.
},
xlabel={Keyword Frequency (Code)},
cycle list name=color list,
grid=major,
legend pos=outer north east,
legend style=
{
cells={anchor=west},
outer ysep=0pt,
},
%legend style=
%{
% at={(0,-.2)}, anchor=north west
%},
%
% this sets the window of values to be displayed
xmin=0,
xmax=11.5,
ymin=0,
every axis plot post/.style={very thick},
]
\addplot coordinates {(1,5)(2,5)(3,4)(4,5)(5,5)(6,5)(7,5)(8,5)(9,5)(10,5)};
\addplot coordinates {(1,9)(2,6)(3,6)(4,5)(5,4)(6,5)(7,6)(8,5)(9,5)(10,5)};
%% Color difference was not sufficient in default, forcing new colour
\pgfplotsset{cycle list shift=+2}
\addplot coordinates {(1,6)(2,7)(3,7)(4,6)(5,7)(6,9)(7,10)(8,10)(9,9)(10,9)};
%% Color difference was not sufficient in default, forcing new colour
\pgfplotsset{cycle list shift=+2}
\addplot coordinates {(1,7)(2,6)(3,5)(4,5)(5,7)(6,4)(7,4)(8,4)(9,4)(10,5)};
\legend{WordCount,KeywordRelevance,KeywordCount,DISCOKeywords}
\end{axis}
\end{tikzpicture}
\end{document}